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

Method Add

collections.go:79–95  ·  view source on GitHub ↗

Add adds a single object to a collection.

(ctx context.Context, collection string, object CollectionObject, opts ...AddObjectOption)

Source from the content-addressed store, hash-verified

77
78// Add adds a single object to a collection.
79func (c *CollectionsClient) Add(ctx context.Context, collection string, object CollectionObject, opts ...AddObjectOption) (*CollectionObjectResponse, error) {
80 if collection == "" {
81 return nil, errors.New("collection name required")
82 }
83 endpoint := c.client.makeEndpoint("collections/%s/", collection)
84
85 req := addCollectionRequest{}
86
87 for _, opt := range opts {
88 opt(&req)
89 }
90
91 req.ID = object.ID
92 req.Data = object.Data
93
94 return c.decodeObject(c.client.post(ctx, endpoint, req, c.client.authenticator.collectionsAuth))
95}
96
97// Get retrieves a collection object having the given ID.
98func (c *CollectionsClient) Get(ctx context.Context, collection, id string) (*CollectionObjectResponse, error) {

Callers

nothing calls this directly

Calls 3

decodeObjectMethod · 0.95
makeEndpointMethod · 0.80
postMethod · 0.80

Tested by

no test coverage detected