Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the new docs "batch write" endpoint #132

Closed
EricBorczuk opened this issue Jun 24, 2021 · 1 comment
Closed

Add the new docs "batch write" endpoint #132

EricBorczuk opened this issue Jun 24, 2021 · 1 comment

Comments

@EricBorczuk
Copy link
Collaborator

EricBorczuk commented Jun 24, 2021

See stargate/stargate#1043 for technical details

An endpoint was added that allows a user to send a single request to create multiple documents at once. The format of such a request is:

POST /api/v2/namespaces/:namespace/collections/:collection/batch

[
    {"data": "doc1", "some":"info"},
    {"data": "doc2", "some":"info"},
    {"data": "doc3", "some":"info"},
    {"data": "doc4", "some":"info"},
]

This will create 4 new documents with ID's that are generated UUID's. The response:

202 Accepted

{ "documentIds": [...] }

Optionally, an id-path query parameter can be supplied, which allows taking a particular path within each document and using that as an ID. as an example:

POST /api/v2/namespaces/:namespace/collections/:collection/batch?id-path=data.[0]

[
    {"data": ["doc1"], "some":"info"},
    {"data": ["doc2"], "some":"info"},
    {"data": ["doc3"], "some":"info"},
    {"data": ["doc4"], "some":"info"},
]

This will create 4 new documents with ID's that come from the documents themselves. The response:

202 Accepted

{ "documentIds": ["doc1", "doc2", "doc3", "doc4"] }
@polandll
Copy link
Collaborator

#217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants