[Add] Func delete document + index

This commit is contained in:
trunglt251292 2022-03-15 15:03:26 +07:00
parent a4b47bb79b
commit bded4de2eb
1 changed files with 9 additions and 2 deletions

View File

@ -116,12 +116,19 @@ func (c *Client) CreateIndex(name string) (bool, error) {
ApiKey: c.Config.ApiKey, ApiKey: c.Config.ApiKey,
Body: toBytes(name), Body: toBytes(name),
} }
res *Response
) )
err := c.natsJetStream.Publish(JetStreamSearchService, SubjectCreateIndex, toBytes(req)) msg, err := c.natsServer.Request(SubjectCreateIndex, toBytes(req))
if err != nil { if err != nil {
return false, err return false, err
} }
return true, nil if err = json.Unmarshal(msg.Data, &res); err != nil {
return false, err
}
if res.Message != "" {
return false, errors.New(res.Message)
}
return res.Success, nil
} }
func toBytes(data interface{}) []byte { func toBytes(data interface{}) []byte {