Replace
Replace document by specified filter or Id.
Replace the entire document with a new one. When you want to update the document, and you don't know which part will be updated each time, you can update that document by replacing it entirely.
Replace the entire document with a new one. When you want to update the document, and you don't know which part will be updated each time, you can update that document by replacing it entirely. https://docs.codemash.io/api/database/collections/replace
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
By default file uploads are done after the record is updated, set to true in case you need to wait for files to be uploaded.
If true, inserts a new record if current record not found
Records are validated against CodeMash JSON Schema before each update. That can slow down API performance. If you have already validated your data with JSON Schema and you can assure of data integrity, you can bypass document validation by setting this property to true.
Triggers are called each time you update the document. You can disable triggers if it's not needed. This is really important when you update the database from trigger itself, so then you can avoid infinite loop.
If your document has file field(s), then you set field value with Id that comes from your file storage provider. E.g.: When your file provider is AWS S3, so then you can set field value to S3 file key, and this will be automatically combined between your file service provider and CodeMash.
Success
PUT /{version}/db/{CollectionName}/replaceOne HTTP/1.1
Host: api.codemash.io/
Authorization: YOUR_API_KEY
Accept: application/json
X-CM-ProjectId: text
Content-Type: application/x-www-form-urlencoded
Content-Length: 124
"WaitForFileUpload=true&IsUpsert=true&BypassDocumentValidation=true&IgnoreTriggers=true&ResolveProviderFiles=true"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": {
"isAcknowledged": null,
"isModifiedCountAvailable": null,
"matchedCount": null,
"modifiedCount": null,
"upsertedId": "text"
}
}Last updated
Was this helpful?