Select returns a list of CollectionObjects for the given collection name having the given IDs.
(ctx context.Context, collection string, ids ...string)
| 30 | // Select returns a list of CollectionObjects for the given collection name |
| 31 | // having the given IDs. |
| 32 | func (c *CollectionsClient) Select(ctx context.Context, collection string, ids ...string) (*GetCollectionResponse, error) { |
| 33 | if collection == "" { |
| 34 | return nil, errors.New("collection name required") |
| 35 | } |
| 36 | foreignIDs := make([]string, len(ids)) |
| 37 | for i := range ids { |
| 38 | foreignIDs[i] = fmt.Sprintf("%s:%s", collection, ids[i]) |
| 39 | } |
| 40 | endpoint := c.client.makeEndpoint("collections/") |
| 41 | endpoint.addQueryParam(makeRequestOption("foreign_ids", strings.Join(foreignIDs, ","))) |
| 42 | resp, err := c.client.get(ctx, endpoint, nil, c.client.authenticator.collectionsAuth) |
| 43 | if err != nil { |
| 44 | return nil, err |
| 45 | } |
| 46 | var result getCollectionResponseWrap |
| 47 | if err := json.Unmarshal(resp, &result); err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | return &GetCollectionResponse{ |
| 51 | response: result.response, |
| 52 | Objects: result.Response.Data, |
| 53 | }, nil |
| 54 | } |
| 55 | |
| 56 | // DeleteMany removes from a collection the objects having the given IDs. |
| 57 | func (c *CollectionsClient) DeleteMany(ctx context.Context, collection string, ids ...string) (*BaseResponse, error) { |