Add adds a single object to a collection.
(ctx context.Context, collection string, object CollectionObject, opts ...AddObjectOption)
| 77 | |
| 78 | // Add adds a single object to a collection. |
| 79 | func (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. |
| 98 | func (c *CollectionsClient) Get(ctx context.Context, collection, id string) (*CollectionObjectResponse, error) { |
nothing calls this directly
no test coverage detected