Delete Documents删除文件

This page provides examples in:本页提供了以下示例:

This page uses the following mongo shell methods:此页面使用以下mongo shell方法:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses MongoDB Compass to delete the documents.此页面使用MongoDB Compass删除文档。

Populate the inventory collection with the following documents:使用以下文档填充inventory集合:

This page uses the following PyMongo Python driver methods:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following Java Synchronous Driver methods:此页面使用以下Java同步驱动程序方法:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following MongoDB Node.js Driver methods:此页面使用以下MongoDB Node.js驱动程序方法:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following MongoDB PHP Library methods:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following Motor driver methods:

  • motor.motor_asyncio.AsyncIOMotorCollection.delete_many()
  • motor.motor_asyncio.AsyncIOMotorCollection.delete_one()

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following Java Reactive Streams Driver methods:此页面使用以下Java反应流驱动程序方法:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following MongoDB C# Driver methods:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following MongoDB Perl Driver methods:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following MongoDB Ruby Driver methods:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following MongoDB Scala Driver methods:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

This page uses the following MongoDB Go Driver functions:

The examples on this page use the inventory collection. 本页上的示例使用inventory集合。To populate the inventory collection, run the following:要填充inventory集合,请运行以下操作:

db.inventory.insertMany( [
   { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
   { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" },
   { item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
   { item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
   { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
] );

You can run the operation in the web shell below:您可以在下面的web shell中运行该操作:

[
   { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
   { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" },
   { item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
   { item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
   { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
]

For instructions on inserting documents in MongoDB Compass, see Insert Documents.有关在MongoDB Compass中插入文档的说明,请参阅插入文档

Note

For complete reference on inserting documents in MongoDB Compass, see the Compass documentation.有关在MongoDB Compass中插入文档的完整参考,请参阅Compass文档

db.inventory.insert_many([
    {"item": "journal",
     "qty": 25,
     "size": {"h": 14, "w": 21, "uom": "cm"},
     "status": "A"},
    {"item": "notebook",
     "qty": 50,
     "size": {"h": 8.5, "w": 11, "uom": "in"},
     "status": "P"},
    {"item": "paper",
     "qty": 100,
     "size": {"h": 8.5, "w": 11, "uom": "in"},
     "status": "D"},
    {"item": "planner",
     "qty": 75,
     "size": {"h": 22.85, "w": 30, "uom": "cm"},
     "status": "D"},
    {"item": "postcard",
     "qty": 45,
     "size": {"h": 10, "w": 15.25, "uom": "cm"},
     "status": "A"}])
collection.insertMany(asList(
        Document.parse("{ item: 'journal', qty: 25, size: { h: 14, w: 21, uom: 'cm' }, status: 'A' }"),
        Document.parse("{ item: 'notebook', qty: 50, size: { h: 8.5, w: 11, uom: 'in' }, status: 'A' }"),
        Document.parse("{ item: 'paper', qty: 100, size: { h: 8.5, w: 11, uom: 'in' }, status: 'D' }"),
        Document.parse("{ item: 'planner', qty: 75, size: { h: 22.85, w: 30, uom: 'cm' }, status: 'D' }"),
        Document.parse("{ item: 'postcard', qty: 45, size: { h: 10, w: 15.25, uom: 'cm' }, status: 'A' }")
));
await db.collection('inventory').insertMany([
  {
    item: 'journal',
    qty: 25,
    size: { h: 14, w: 21, uom: 'cm' },
    status: 'A'
  },
  {
    item: 'notebook',
    qty: 50,
    size: { h: 8.5, w: 11, uom: 'in' },
    status: 'P'
  },
  {
    item: 'paper',
    qty: 100,
    size: { h: 8.5, w: 11, uom: 'in' },
    status: 'D'
  },
  {
    item: 'planner',
    qty: 75,
    size: { h: 22.85, w: 30, uom: 'cm' },
    status: 'D'
  },
  {
    item: 'postcard',
    qty: 45,
    size: { h: 10, w: 15.25, uom: 'cm' },
    status: 'A'
  }
]);
$insertManyResult = $db->inventory->insertMany([
    [
        'item' => 'journal',
        'qty' => 25,
        'size' => ['h' => 14, 'w' => 21, 'uom' => 'cm'],
        'status' => 'A',
    ],
    [
        'item' => 'notebook',
        'qty' => 50,
        'size' => ['h' => 8.5, 'w' => 11, 'uom' => 'in'],
        'status' => 'P',
    ],
    [
        'item' => 'paper',
        'qty' => 100,
        'size' => ['h' => 8.5, 'w' => 11, 'uom' => 'in'],
        'status' => 'D',
    ],
    [
        'item' => 'planner',
        'qty' => 75,
        'size' => ['h' => 22.85, 'w' => 30, 'uom' => 'cm'],
        'status' => 'D',
    ],
    [
        'item' => 'postcard',
        'qty' => 45,
        'size' => ['h' => 10, 'w' => 15.25, 'uom' => 'cm'],
        'status' => 'A',
    ],
]);
await db.inventory.insert_many([
    {"item": "journal",
     "qty": 25,
     "size": {"h": 14, "w": 21, "uom": "cm"},
     "status": "A"},
    {"item": "notebook",
     "qty": 50,
     "size": {"h": 8.5, "w": 11, "uom": "in"},
     "status": "P"},
    {"item": "paper",
     "qty": 100,
     "size": {"h": 8.5, "w": 11, "uom": "in"},
     "status": "D"},
    {"item": "planner",
     "qty": 75,
     "size": {"h": 22.85, "w": 30, "uom": "cm"},
     "status": "D"},
    {"item": "postcard",
     "qty": 45,
     "size": {"h": 10, "w": 15.25, "uom": "cm"},
     "status": "A"}])
Publisher<Success> insertManyPublisher = collection.insertMany(asList(
        Document.parse("{ item: 'journal', qty: 25, size: { h: 14, w: 21, uom: 'cm' }, status: 'A' }"),
        Document.parse("{ item: 'notebook', qty: 50, size: { h: 8.5, w: 11, uom: 'in' }, status: 'A' }"),
        Document.parse("{ item: 'paper', qty: 100, size: { h: 8.5, w: 11, uom: 'in' }, status: 'D' }"),
        Document.parse("{ item: 'planner', qty: 75, size: { h: 22.85, w: 30, uom: 'cm' }, status: 'D' }"),
        Document.parse("{ item: 'postcard', qty: 45, size: { h: 10, w: 15.25, uom: 'cm' }, status: 'A' }")
));
var documents = new[]
{
    new BsonDocument
    {
        { "item", "journal" },
        { "qty", 25 },
        { "size", new BsonDocument { { "h", 14 }, { "w", 21 }, { "uom", "cm" } } },
        { "status", "A" }
    },
    new BsonDocument
    {
        { "item", "notebook" },
        { "qty", 50 },
        { "size", new BsonDocument { { "h", 8.5 }, { "w", 11 }, { "uom", "in" } } },
        { "status", "P" }
    },
    new BsonDocument
    {
        { "item", "paper" },
        { "qty", 100 },
        { "size", new BsonDocument { { "h", 8.5 }, { "w", 11 }, { "uom", "in" } } },
        { "status", "D" }
    },
    new BsonDocument
    {
        { "item", "planner" },
        { "qty", 75 },
        { "size", new BsonDocument { { "h", 22.85 }, { "w", 30 }, { "uom", "cm" } } },
        { "status", "D" }
    },
    new BsonDocument
    {
        { "item", "postcard" },
        { "qty", 45 },
        { "size", new BsonDocument { { "h", 10 }, { "w", 15.25 }, { "uom", "cm" } } },
        { "status", "A" }
    }
};
collection.InsertMany(documents);
$db->coll("inventory")->insert_many(
    [
        {
            item   => "journal",
            qty    => 25,
            size   => { h => 14, w => 21, uom => "cm" },
            status => "A"
        },
        {
            item   => "notebook",
            qty    => 50,
            size   => { h => 8.5, w => 11, uom => "in" },
            status => "P"
        },
        {
            item   => "paper",
            qty    => 100,
            size   => { h => 8.5, w => 11, uom => "in" },
            status => "D"
        },
        {
            item   => "planner",
            qty    => 75,
            size   => { h => 22.85, w => 30, uom => "cm" },
            status => "D"
        },
        {
            item   => "postcard",
            qty    => 45,
            size   => { h => 10, w => 15.25, uom => "cm" },
            status => "A"
        }
    ]
);
client[:inventory].insert_many([
                                { item: 'journal',
                                  qty: 25,
                                  size: { h: 14, w: 21, uom: 'cm' },
                                  status: 'A' },
                                { item: 'notebook',
                                  qty: 50,
                                  size: { h: 8.5, w: 11, uom: 'in' },
                                  status: 'P' },
                                { item: 'paper',
                                  qty: 100,
                                  size: { h: 8.5, w: 11, uom: 'in' },
                                  status: 'D' },
                                { item: 'planner',
                                  qty: 75,
                                  size: { h: 22.85, w: 30, uom: 'cm' },
                                  status: 'D' },
                                { item: 'postcard',
                                  qty: 45,
                                  size: { h: 10, w: 15.25, uom: 'cm' },
                                  status: 'A' },
                               ])
collection.insertMany(Seq(
  Document("""{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" }"""),
  Document("""{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" }"""),
  Document("""{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" }"""),
  Document("""{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" }"""),
  Document("""{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }""")
)).execute()
docs := []interface{}{
	bson.D{
		{"item", "journal"},
		{"qty", 25},
		{"size", bson.D{
			{"h", 14},
			{"w", 21},
			{"uom", "cm"},
		}},
		{"status", "A"},
	},
	bson.D{
		{"item", "notebook"},
		{"qty", 50},
		{"size", bson.D{
			{"h", 8.5},
			{"w", 11},
			{"uom", "in"},
		}},
		{"status", "P"},
	},
	bson.D{
		{"item", "paper"},
		{"qty", 100},
		{"size", bson.D{
			{"h", 8.5},
			{"w", 11},
			{"uom", "in"},
		}},
		{"status", "D"},
	},
	bson.D{
		{"item", "planner"},
		{"qty", 75},
		{"size", bson.D{
			{"h", 22.85},
			{"w", 30},
			{"uom", "cm"},
		}},
		{"status", "D"},
	},
	bson.D{
		{"item", "postcard"},
		{"qty", 45},
		{"size", bson.D{
			{"h", 10},
			{"w", 15.25},
			{"uom", "cm"},
		}},
		{"status", "A"},
	},
}

result, err := coll.InsertMany(context.Background(), docs)

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter document {} to the db.collection.deleteMany() method.要删除集合中的所有文档,请将空的筛选器文档{}传递给db.collection.deleteMany()方法。

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter document {} to the pymongo.collection.Collection.delete_many() method.

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty org.bson.Document object as the filter to the com.mongodb.client.MongoCollection.deleteMany method.要从集合中删除所有文档,请将空的org.bson.Document对象作为筛选器传递给com.mongodb.client.MongoCollection.deleteMany方法。

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter document {} to the Collection.deleteMany() method.要删除集合中的所有文档,请将空的筛选器文档{}传递给Collection.deleteMany()方法。

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter document [] to the MongoDB\Collection::deleteMany() method.

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter document {} to the motor.motor_asyncio.AsyncIOMotorCollection.delete_many() method.

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty org.bson.Document object as the filter to the com.mongodb.reactivestreams.client.MongoCollection.deleteMany method.要从集合中删除所有文档,请将空的org.bson.Document对象作为筛选器传递给com.mongodb.reactivestreams.client.MongoCollection.deleteMany方法。

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter Builders<BsonDocument>.Filter.Empty to the IMongoCollection.DeleteMany() method.

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter document {} to the MongoDB::Collection::delete_many() method.

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter document {} to the Mongo::Collection#delete_many() method.

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter Document() to the collection.deleteMany() method.

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

Delete All Documents删除所有文档

To delete all documents from a collection, pass an empty filter document to the Collection.DeleteMany function.

The following example deletes all documents from the inventory collection:以下示例从inventory集合中删除所有文档:

db.inventory.deleteMany({})
db.inventory.delete_many({})
collection.deleteMany(new Document());
await db.collection('inventory').deleteMany({});
$deleteResult = $db->inventory->deleteMany([]);
await db.inventory.delete_many({})
Publisher<DeleteResult> deleteManyPublisher = collection.deleteMany(new Document());
var filter = Builders<BsonDocument>.Filter.Empty;
var result = collection.DeleteMany(filter);
$db->coll("inventory")->delete_many( {} );
client[:inventory].delete_many({})
collection.deleteMany(Document()).execute()
result, err := coll.DeleteMany(context.Background(), bson.D{})

The method returns a document with the status of the operation. 该方法返回一个带有操作状态的文档。For more information and examples, see deleteMany().有关更多信息和示例,请参阅deleteMany()

The delete_many() method returns an instance of pymongo.results.DeleteResult with the status of the operation.

The com.mongodb.client.MongoCollection.deleteMany method returns an instance of com.mongodb.client.result.DeleteResult with the status of the operation.com.mongodb.client.MongoCollection.deleteMany方法返回com.mongodb.client.result.DeleteResult的一个实例,带有操作状态。

deleteMany() returns a promise that provides a result. deleteMany()返回提供结果的承诺。The result.deletedCount property contains the number of documents that matched the filter.result.deletedCount属性包含与筛选器匹配的文档数。

Upon successful execution, the deleteMany() method returns an instance of MongoDB\DeleteResult whose getDeletedCount() method returns the number of documents that matched the filter.

The delete_many() coroutine asynchronously returns an instance of pymongo.results.DeleteResult with the status of the operation.

com.mongodb.reactivestreams.client.MongoCollection.deleteMany returns a Publisher object of type com.mongodb.client.result.DeleteResult if successful. 如果成功,com.mongodb.reactivestreams.client.MongoCollection.deleteMany将返回com.mongodb.client.result.DeleteResult类型的Publisher对象。Returns an instance of com.mongodb.MongoException if unsuccessful.如果失败,则返回com.mongodb.MongoException的实例。

Upon successful execution, the IMongoCollection.DeleteMany() method returns an instance of DeleteResult whose DeletedCount property contains the number of documents that matched the filter.

Upon successful execution, the delete_many() method returns an instance of MongoDB::DeleteResult whose deleted_count attribute contains the number of documents that matched the filter.

Upon successful execution, the delete_many() method returns an instance of Mongo::Operation::Result, whose deleted_count attribute contains the number of documents that matched the filter.

Upon successful execution, the collection.deleteMany() method returns an Observable with a single element with a DeleteResult type parameter or with an com.mongodb.MongoException.

Upon successful execution, the Collection.DeleteMany function returns an instance of DeleteResult whose DeletedCount property contains the number of documents that matched the filter.

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. 您可以指定用于标识要删除的文档的条件或筛选器。The filters use the same syntax as read operations.筛选器使用与读取操作相同的语法。

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq_方法创建查询筛选器文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq方法创建查询筛选文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the deleteMany() method.要删除符合删除条件的所有文档,请将筛选器参数传递给deleteMany()方法。

The following example removes all documents from the inventory collection where the status field equals "A":以下示例从inventory集合中删除status字段等于"A"的所有文档:

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. 您可以指定用于标识要删除的文档的条件或筛选器。The filters use the same syntax as read operations.筛选器使用与读取操作相同的语法。

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq_方法创建查询筛选器文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq方法创建查询筛选文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the delete_many() method.要删除符合删除条件的所有文档,请将筛选器参数传递给delete_many()方法。

The following example removes all documents from the inventory collection where the status field equals "A":以下示例从inventory集合中删除status字段等于"A"的所有文档:

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. 您可以指定用于标识要删除的文档的条件或筛选器。The filters use the same syntax as read operations.筛选器使用与读取操作相同的语法。

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq_方法创建查询筛选器文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq方法创建查询筛选文档:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the com.mongodb.client.MongoCollection.deleteMany method.要删除符合删除条件的所有文档,请将筛选器参数传递给com.mongodb.client.MongoCollection.deleteMany方法。

The following example removes all documents from the inventory collection where the status field equals "A":以下示例从inventory集合中删除status字段等于"A"的所有文档:

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. 您可以指定用于标识要删除的文档的条件或筛选器。The filters use the same syntax as read operations.筛选器使用与读取操作相同的语法。

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq_方法创建查询筛选器文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq方法创建查询筛选文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the deleteMany() method.要删除符合删除条件的所有文档,请将筛选器参数传递给deleteMany()方法。

The following example removes all documents from the inventory collection where the status field equals "A":以下示例从inventory集合中删除status字段等于"A"的所有文档:

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. The filters use the same syntax as read operations.

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq方法创建查询筛选文档:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the deleteMany() method.

The following example removes all documents from the inventory collection where the status field equals "A":

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. The filters use the same syntax as read operations.

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq方法创建查询筛选文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the delete_many() method.

The following example removes all documents from the inventory collection where the status field equals "A":

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. 您可以指定用于标识要删除的文档的条件或筛选器。The filters use the same syntax as read operations.筛选器使用与读取操作相同的语法。

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq_方法创建查询筛选器文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters方法创建查询筛选文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters_助手方法促进筛选文档的创建。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the com.mongodb.reactivestreams.client.MongoCollection.deleteMany method.要删除符合删除条件的所有文档,请将筛选器参数传递给com.mongodb.reactivestreams.client.MongoCollection.deleteMany方法。

The following example removes all documents from the inventory collection where the status field equals "A":以下示例从inventory集合中删除status字段等于"A"的所有文档:

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. The filters use the same syntax as read operations.

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the IMongoCollection.DeleteMany() method.

The following example removes all documents from the inventory collection where the status field equals "A":

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. The filters use the same syntax as read operations.

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq_方法创建查询筛选器文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the delete_many() method.

The following example removes all documents from the inventory collection where the status field equals "A":

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. The filters use the same syntax as read operations.

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the delete_many() method.

The following example removes all documents from the inventory collection where the status field equals "A":

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. The filters use the same syntax as read operations.

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq_方法创建查询筛选器文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the deleteMany() method.

The following example removes all documents from the inventory collection where the status field equals "A":

Delete All Documents that Match a Condition删除符合条件的所有文档

You can specify criteria, or filters, that identify the documents to delete. The filters use the same syntax as read operations.

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:要指定相等条件,请使用com.mongodb.client.model.Filters.eq_方法创建查询筛选器文档

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, use <field>:<value> expressions in the query filter document:要指定相等条件,请在查询筛选文档中使用<field>:<value>表达式:

{ <field1>: <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

[ <field1> => <value1>, ... ]

To specify equality conditions, use <field>:<value> expressions in the query filter document:

{ <field1>: <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq method to create the query filter document:

and(eq( <field1>, <value1>), eq( <field2>, <value2>) ...)

To specify equality conditions, construct a filter using the Eq method:

Builders<BsonDocument>.Filter.Eq(<field>, <value>);

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use <field> => <value> expressions in the query filter document:

{ <field1> => <value1>, ... }

To specify equality conditions, use the com.mongodb.client.model.Filters.eq_ method to create the query filter document:

and(equal(<field1>, <value1>), equal(<field2>, <value2>) ...)

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. 除了相等条件外,MongoDB还提供了各种查询运算符来指定筛选条件。Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. 使用com.mongodb.client.model.Filters助手方法来帮助创建筛选文档。For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

A query filter document can use the query operators to specify conditions in the following form:查询筛选文档可以使用查询运算符以以下形式指定条件:

{ <field1>: { <operator1>: <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

[ <field1> => [ <operator1> => <value1> ], ... ]

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), eq(<field3>, <value3>))

In addition to the equality filter, MongoDB provides various query operators to specify filter conditions. Use the FilterDefinitionBuilder methods to create a filter document. For example:例如:

var builder = Builders<BsonDocument>.Filter;
builder.And(builder.Eq(<field1>, <value1>), builder.Lt(<field2>, <value2>));

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

A query filter document can use the query operators to specify conditions in the following form:

{ <field1> => { <operator1> => <value1> }, ... }

In addition to the equality condition, MongoDB provides various query operators to specify filter conditions. Use the com.mongodb.client.model.Filters_ helper methods to facilitate the creation of filter documents. For example:例如:

and(gte(<field1>, <value1>), lt(<field2>, <value2>), equal(<field3>, <value3>))

To delete all documents that match a deletion criteria, pass a filter parameter to the Collection.DeleteMany function.

The following example removes all documents from the inventory collection where the status field equals "A":

db.inventory.deleteMany({ status : "A" })
db.inventory.delete_many({"status": "A"})
collection.deleteMany(eq("status", "A"));
await db.collection('inventory').deleteMany({ status: 'A' });
$deleteResult = $db->inventory->deleteMany(['status' => 'A']);
await db.inventory.delete_many({"status": "A"})
deleteManyPublisher = collection.deleteMany(eq("status", "A"));
var filter = Builders<BsonDocument>.Filter.Eq("status", "A");
var result = collection.DeleteMany(filter);
$db->coll("inventory")->delete_many( { status => "A" } );
client[:inventory].delete_many(status: 'A')
collection.deleteMany(equal("status", "A")).execute()
result, err := coll.DeleteMany(
	context.Background(),
	bson.D{
		{"status", "A"},
	},
)

The method returns a document with the status of the operation. 该方法返回一个带有操作状态的文档。For more information and examples, see deleteMany().有关更多信息和示例,请参阅deleteMany()

The delete_many() method returns an instance of pymongo.results.DeleteResult with the status of the operation.

The com.mongodb.client.MongoCollection.deleteMany method returns an instance of com.mongodb.client.result.DeleteResult with the status of the operation.com.mongodb.client.MongoCollection.deleteMany方法返回com.mongodb.client.result.DeleteResult的一个实例,带有操作状态。

deleteMany() returns a promise that provides a result. deleteMany()返回提供result的承诺。The result.deletedCount property contains the number of documents that matched the filter.result.deletedCount属性包含与筛选器匹配的文档数。

Upon successful execution, the deleteMany() method returns an instance of MongoDB\DeleteResult whose getDeletedCount() method returns the number of documents that matched the filter.

The delete_many() coroutine asynchronously returns an instance of pymongo.results.DeleteResult with the status of the operation.

com.mongodb.reactivestreams.client.MongoCollection.deleteMany returns a Publisher object of type com.mongodb.client.result.DeleteResult if successful. 如果成功,com.mongodb.reactivestreams.client.MongoCollection.deleteMany将返回com.mongodb.client.result.DeleteResult类型的Publisher对象。Returns an instance of com.mongodb.MongoException if unsuccessful.如果失败,则返回com.mongodb.MongoException的实例。

Upon successful execution, the IMongoCollection.DeleteMany() method returns an instance of DeleteResult whose DeletedCount property contains the number of documents that matched the filter.

Upon successful execution, the delete_many() method returns an instance of MongoDB::DeleteResult whose deleted_count attribute contains the number of documents that matched the filter.

Upon successful execution, the delete_many() method returns an instance of Mongo::Operation::Result, whose deleted_count attribute contains the number of documents that matched the filter.

Upon successful execution, the collection.deleteMany() method returns an Observable with a single element with a DeleteResult type parameter or with an com.mongodb.MongoException.

Upon successful execution, the Collection.DeleteMany function returns an instance of DeleteResult whose DeletedCount property contains the number of documents that matched the filter.

Delete Only One Document that Matches a Condition仅删除一个符合条件的文档

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the db.collection.deleteOne() method.要最多删除与指定筛选器匹配的单个文档(即使多个文档可能与指定筛选器匹配),请使用db.collection.deleteOne()方法。

The following example deletes the first document where status is "D":以下示例删除status"D"的第一个文档:

Delete a Single Document删除单个文档

MongoDB Compass provides a simple way to delete a document from a collection. MongoDB Compass提供了一种从集合中删除文档的简单方法。The following example shows how to delete the document with item equal to paper from the inventory collection:以下示例显示如何从inventory集合中删除item等于paper的文档:

Note

In this example we are using the Compass Table View to delete the document. 在本例中,我们使用Compass表格视图删除文档。The deletion process using the Compass List View follows a very similar approach.使用Compass列表视图的删除过程遵循非常类似的方法。

For more information on the differences between Table View and List View in Compass, refer to the Compass documentation.有关Compass中表格视图和列表视图之间差异的更多信息,请参阅Compass文档

Delete Only One Document that Matches a Condition仅删除一个符合条件的文档

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the pymongo.collection.Collection.delete_one() method.要最多删除与指定筛选器匹配的单个文档(即使多个文档可能与指定筛选器匹配),请使用pymongo.collection.Collection.delete_one()方法。

The following example deletes the first document where status is "D":

Delete Only One Document that Matches a Condition仅删除一个符合条件的文档

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the com.mongodb.client.MongoCollection.deleteOne method.要最多删除与指定筛选器匹配的单个文档(即使多个文档可能与指定筛选器匹配),请使用com.mongodb.client.MongoCollection.deleteOne方法。

The following example deletes the first document where status is "D":以下示例删除status"D"的第一个文档:

Delete Only One Document that Matches a Condition仅删除一个符合条件的文档

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the Collection.deleteOne() method.要最多删除与指定筛选器匹配的单个文档(即使多个文档可能与指定筛选器匹配),请使用Collection.deleteOne()方法。

The following example deletes the first document where status is "D":以下示例删除status"D"的第一个文档:

Delete Only One Document that Matches a Condition

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the MongoDB\Collection::deleteOne() method.

The following example deletes the first document where status is "D":

Delete Only One Document that Matches a Condition

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the motor.motor_asyncio.AsyncIOMotorCollection.delete_one() method.

The following example deletes the first document where status is "D":

Delete Only One Document that Matches a Condition仅删除一个符合条件的文档

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the com.mongodb.reactivestreams.client.MongoCollection.deleteMany method.要最多删除与指定筛选器匹配的单个文档(即使多个文档可能与指定筛选器匹配),请使用com.mongodb.reactivestreams.client.MongoCollection.deleteMany方法。

The following example deletes the first document where status is "D":以下示例删除status"D"的第一个文档:

Delete Only One Document that Matches a Condition

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the IMongoCollection.DeleteOne() method.

The following example deletes the first document where status is "D":

Delete Only One Document that Matches a Condition

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the MongoDB::Collection::delete_one() method.

The following example deletes the first document where status is "D":

Delete Only One Document that Matches a Condition

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the Mongo::Collection#delete_one() method.

The following example deletes the first document where status is "D":

Delete Only One Document that Matches a Condition

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the collection.deleteOne() method.

The following example deletes the first document where status is "D":

Delete Only One Document that Matches a Condition

To delete at most a single document that matches a specified filter (even though multiple documents may match the specified filter) use the Collection.DeleteOne function.

The following example deletes the first document where status is "D":

db.inventory.deleteOne( { status: "D" } )
  1. Click the Table button in the top navigation to access the Table View:单击顶部导航中的“表格”按钮以访问表格视图

    ../../_images/compass-table-btn-click-2.png

  2. Use the Compass query bar to locate the target document.使用Compass查询栏定位目标文档。

    Copy the following filter document into the query bar and click Find:将以下筛选文档复制到查询栏中,然后单击“查找”:

    { item: "paper" }
    ../../_images/compass-delete-paper-find.png

  3. Hover over the document and click the trash icon which appears on the right-hand side:将鼠标悬停在文档上,然后单击右侧显示的垃圾箱图标:


    ../../_images/compass-delete-button-click.png

    After clicking the delete button, the document is flagged for deletion and Compass asks for confirmation that you want to remove the document:单击“删除”按钮后,文档将被标记为删除,Compass要求确认是否要删除该文档:


    ../../_images/compass-delete-confirm.png

  4. Click Delete to confirm. Compass deletes the document from the collection.单击“删除”以确认。Compass从集合中删除文档。
db.inventory.delete_one({"status": "D"})
collection.deleteOne(eq("status", "D"));
await db.collection('inventory').deleteOne({ status: 'D' });
$deleteResult = $db->inventory->deleteOne(['status' => 'D']);
await db.inventory.delete_one({"status": "D"})
Publisher<DeleteResult> deleteOnePublisher = collection.deleteOne(eq("status", "D"));
var filter = Builders<BsonDocument>.Filter.Eq("status", "D");
var result = collection.DeleteOne(filter);
$db->coll("inventory")->delete_one( { status => "D" } );
client[:inventory].delete_one(status: 'D')
collection.deleteOne(equal("status", "D")).execute()
result, err := coll.DeleteOne(
	context.Background(),
	bson.D{
		{"status", "D"},
	},
)

Delete Behavior删除行为

Indexes索引

Delete operations do not drop indexes, even if deleting all documents from a collection.删除操作不会删除索引,即使从集合中删除所有文档也是如此。

Atomicity原子性

All write operations in MongoDB are atomic on the level of a single document. MongoDB中的所有写操作都是单个文档级别的原子操作。For more information on MongoDB and atomicity, see Atomicity and Transactions.有关MongoDB和原子性的更多信息,请参阅原子性和事务

Write Acknowledgement写确认

With write concerns, you can specify the level of acknowledgement requested from MongoDB for write operations. 对于写操作,您可以指定MongoDB为写操作请求的确认级别。For details, see Write Concern.有关详细信息,请参阅写关注事项