INSERT
POSThttps://cloud.singlebaseapis.com/api
The INSERT statement is used to insert one or multiple documents into a collection.
INSERT statement syntax
//--- short form
INSERT [$data] IN [collection_name];
//--- long form
INSERT INTO [collection_name] VALUES [$data]
Query Example
// insert one document
{
"query": "INSERT $data IN articles",
"variables": {
"data": {
"title": "Doc 1",
...
}
}
}
// Insert multiple documents
{
"query": "INSERT INTO articles VALUES $data",
"variables": {
"data": [
{
"title": "Doc 1",
...
},
{
"title": "Doc 2",
...
},
{
"title": "Doc 3",
...
}
]
}
}
Request
- application/json
Body
query stringrequired
The X-SQL Query string
variables objectrequired
The variables
Responses
- 200
Mutation response
- application/json
- Schema
- Example (from schema)
Schema
data object[]
Array of documents mutated
{
"data": [
{}
]
}
- curl
- python
- go
- nodejs
- ruby
- csharp
- php
- java
- CURL
curl -L -X POST 'https://cloud.singlebaseapis.com/api/' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-API-KEY: <API_KEY_VALUE>' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"query": "string",
"variables": {}
}'
ResponseClear