When you need to update only part of the document, you can specify which properties should be updated. You can benefit from it in many ways: you don't need to prefetch all the data upfront, reduce the payload of a request, increment some property without replacing the entire document, ... If you want to replace the entire document, please refer to ReplaceOne action.
var client =newCodeMashClient(apiKey, projectId);var service =newCodeMashRepository<Person>(client);var person =newPerson { Id ="record_id" Name ="Peter" };var updateDefinition =Builders<Person>.Update.Set(x =>x.Name,"Peter II");awaitservice.UpdateOneRequest( x =>x.Id==person.Id, updateDefinition,newDatabaseUpdateOneOptions());
Check the information about entities on how your class objects are serialized.
import { db } from'codemash';exportasyncfunctionactivateEmployee(id) {returnawaitdb.updateRecord('employees', { _id: id }, { $set: { 'is_active':1 }});}
Error with https://760328771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwSkuCpTNI_AerL8J2a%2Fuploads%2FCpzJktmKXD6FMPSah1nK%2Fopenapi.json?alt=media&token=854cdd6a-61b2-49a5-99f4-6bc091e5c3d6: Failed to convert Swagger 2.0 to OpenAPI 3.0: Operation UpdateManyRequestdbCollectionNamebulk_Update has multiple requestBodies
Error with https://760328771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwSkuCpTNI_AerL8J2a%2Fuploads%2FCpzJktmKXD6FMPSah1nK%2Fopenapi.json?alt=media&token=854cdd6a-61b2-49a5-99f4-6bc091e5c3d6: Failed to convert Swagger 2.0 to OpenAPI 3.0: Operation UpdateManyRequestdbCollectionNamebulk_Update has multiple requestBodies