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

Method Upsert

collections.go:17–28  ·  view source on GitHub ↗

Upsert creates new or updates existing objects for the given collection's name.

(ctx context.Context, collection string, objects ...CollectionObject)

Source from the content-addressed store, hash-verified

15
16// Upsert creates new or updates existing objects for the given collection's name.
17func (c *CollectionsClient) Upsert(ctx context.Context, collection string, objects ...CollectionObject) (*BaseResponse, error) {
18 if collection == "" {
19 return nil, errors.New("collection name required")
20 }
21 endpoint := c.client.makeEndpoint("collections/")
22 data := map[string]any{
23 "data": map[string][]CollectionObject{
24 collection: objects,
25 },
26 }
27 return decode(c.client.post(ctx, endpoint, data, c.client.authenticator.collectionsAuth))
28}
29
30// Select returns a list of CollectionObjects for the given collection name
31// having the given IDs.

Callers 1

Calls 3

decodeFunction · 0.85
makeEndpointMethod · 0.80
postMethod · 0.80

Tested by 1