MCPcopy Create free account
hub / github.com/GetStream/stream-go2 / Select

Method Select

collections.go:32–54  ·  view source on GitHub ↗

Select returns a list of CollectionObjects for the given collection name having the given IDs.

(ctx context.Context, collection string, ids ...string)

Source from the content-addressed store, hash-verified

30// Select returns a list of CollectionObjects for the given collection name
31// having the given IDs.
32func (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.
57func (c *CollectionsClient) DeleteMany(ctx context.Context, collection string, ids ...string) (*BaseResponse, error) {

Callers 1

Calls 4

makeRequestOptionFunction · 0.85
makeEndpointMethod · 0.80
addQueryParamMethod · 0.80
getMethod · 0.80

Tested by 1