Upsert creates new or updates existing objects for the given collection's name.
(ctx context.Context, collection string, objects ...CollectionObject)
| 15 | |
| 16 | // Upsert creates new or updates existing objects for the given collection's name. |
| 17 | func (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. |