Insert Many
Inserts many documents
Use bulk insert when you want to insert many records into the database with one API call. This can be useful when you import data from any other sources.
Use bulk insert when you want to insert many records into database with one API call. This can be useful when you do import data from any other sources. https://docs.codemash.io/api/database/collections/insert-many
Collection name - unique, lowercased, collection name without whitespace. E.g., if your collection title you have entered in the CodeMash dashboard is "Business Trips" then collection name would be "business-trips".
The CodeMash API version used to fetch data from the API. If not specified, the last version will be used. E.g.: v2
Accept Header
API key of your cluster. Can be passed in a header as X-CM-Cluster.
ID of your project. Can be passed in a header as X-CM-ProjectId.
Specify culture code when your response from the API should be localised. E.g.: en
POST //{version}/db/{CollectionName}/bulk HTTP/1.1
Host: api.codemash.io
Authorization: YOUR_API_KEY
X-CM-ProjectId: text
Content-Type: application/json
Accept: */*
Success
{
"response_status": {
"error_code": "text",
"message": "text",
"stack_trace": "text",
"errors": [
{
"error_code": "text",
"field_name": "text",
"message": "text",
"meta": {
"ANY_ADDITIONAL_PROPERTY": "text"
}
}
],
"meta": {
"ANY_ADDITIONAL_PROPERTY": "text"
}
},
"result": [
"text"
]
}
var client = new CodeMashClient(apiKey, projectId);
var service = new CodeMashRepository<Person>(client);
var person1 = new Person { Name = "John" };
var person2 = new Person { Name = "Peter" };
var entities = new List<Person> { person1, person2 };
await service.InsertManyAsync(entities, new DatabaseInsertManyOptions());
Last updated
Was this helpful?