Dica
O MongoDB também fornece o método Mongo.bulkWrite() para executar operações de gravação em massa.
Descrição
Bulk.find.replaceOne(<document>)Adds a single document replacement operation to a bulk operations list. Use the
Bulk.find()method to specify the condition that determines which document to replace. TheBulk.find.replaceOne()method limits the replacement to a single document.Bulk.find.replaceOne()aceita o seguinte parâmetro:ParâmetroTipoDescriçãoreplacementdocumento
A replacement document that completely replaces the existing document. Contém apenas pares de campos e valores.
A soma do documento
<query>associado doBulk.find()e o documento de substituição deve ser menor ou igual ao tamanho máximo do documento BSON.Para especificar um upsert para esta operação, consulte
Bulk.find.upsert().Para especificar o índice a utilizar para o
Bulk.find()associado, consulteBulk.find.hint().
Compatibilidade
Esse comando está disponível em implantações hospedadas nos seguintes ambientes:
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
Observação
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
Exemplo
The following example initializes a Bulk() operations builder for the items collection, and adds various replaceOne() operations to the list of operations.
var bulk = db.items.initializeUnorderedBulkOp(); bulk.find( { item: "abc123" } ).replaceOne( { item: "abc123", status: "P", points: 100 } ); bulk.execute();