[Add] Func delete document + index #3

Merged
trunglt251292 merged 2 commits from v1 into master 2022-03-15 08:04:56 +00:00
1 changed files with 9 additions and 2 deletions
Showing only changes of commit bded4de2eb - Show all commits

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 {