Hướng dẫn what is remove in mongodb? - loại bỏ trong mongodb là gì?

Tài liệu về nhà → Hướng dẫn sử dụng MongoDBMongoDB Manual

Quan trọng

Phương pháp Dành cho Mongosh

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
4Remove tài liệu từ một bộ sưu tập.
Hướng dẫn what is remove in mongodb? - loại bỏ trong mongodb là gì?

Removes documents from a collection.

Phương pháp

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
4 có thể có một trong hai cú pháp. Phương thức
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 có thể lấy tài liệu truy vấn và
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
7 Boolean tùy chọn:
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
4
method can have one of two syntaxes. The
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
method can take a query document and an optional
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
7 boolean:

db.collection.remove(
,
)

Hoặc phương thức có thể lấy tài liệu truy vấn và tài liệu tùy chọn xóa tùy chọn:

Đã thay đổi trong phiên bản 5.0.

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)

Tham số

Loại hình

Sự mô tả

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
8

tài liệu

Chỉ định tiêu chí xóa bằng cách sử dụng các toán tử truy vấn. Để xóa tất cả các tài liệu trong một bộ sưu tập, hãy truyền một tài liệu trống (

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
9).

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
7

boolean

Không bắt buộc. Để giới hạn việc xóa chỉ một tài liệu, được đặt thành

collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
1. Bỏ qua để sử dụng giá trị mặc định của
collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
2 và xóa tất cả các tài liệu phù hợp với tiêu chí xóa.

collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
3

tài liệu

Chỉ định tiêu chí xóa bằng cách sử dụng các toán tử truy vấn. Để xóa tất cả các tài liệu trong một bộ sưu tập, hãy truyền một tài liệu trống (

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
9).Write Concern.

Không bắt buộc. Để giới hạn việc xóa chỉ một tài liệu, được đặt thành

collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
1. Bỏ qua để sử dụng giá trị mặc định của
collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
2 và xóa tất cả các tài liệu phù hợp với tiêu chí xóa.

collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
4

tài liệu

Optional.

Chỉ định tiêu chí xóa bằng cách sử dụng các toán tử truy vấn. Để xóa tất cả các tài liệu trong một bộ sưu tập, hãy truyền một tài liệu trống (

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
9).

Không bắt buộc. Để giới hạn việc xóa chỉ một tài liệu, được đặt thành

collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
1. Bỏ qua để sử dụng giá trị mặc định của
collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
2 và xóa tất cả các tài liệu phù hợp với tiêu chí xóa.

Không bắt buộc. Một tài liệu thể hiện mối quan tâm viết. Bỏ qua để sử dụng mối quan tâm ghi mặc định. Xem Viết mối quan tâm.

collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}

Không đặt rõ ràng mối quan tâm ghi cho hoạt động nếu chạy trong một giao dịch. Để sử dụng viết mối quan tâm với các giao dịch, xem giao dịch và viết mối quan tâm.

Chỉ định đối chiếu để sử dụng cho hoạt động.

Đối chiếu cho phép người dùng chỉ định các quy tắc cụ thể về ngôn ngữ để so sánh chuỗi, chẳng hạn như các quy tắc cho Lettercase và Dấu nhấn.

Tùy chọn đối chiếu có cú pháp sau:

let

tài liệu

Optional.

Chỉ định tiêu chí xóa bằng cách sử dụng các toán tử truy vấn. Để xóa tất cả các tài liệu trong một bộ sưu tập, hãy truyền một tài liệu trống (

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
9).

Không bắt buộc. Để giới hạn việc xóa chỉ một tài liệu, được đặt thành

collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
1. Bỏ qua để sử dụng giá trị mặc định của
collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
2 và xóa tất cả các tài liệu phù hợp với tiêu chí xóa.

{ : ,
...,
: }

Không bắt buộc. Một tài liệu thể hiện mối quan tâm viết. Bỏ qua để sử dụng mối quan tâm ghi mặc định. Xem Viết mối quan tâm.

Không đặt rõ ràng mối quan tâm ghi cho hoạt động nếu chạy trong một giao dịch. Để sử dụng viết mối quan tâm với các giao dịch, xem giao dịch và viết mối quan tâm.

Chỉ định đối chiếu để sử dụng cho hoạt động.

Đối chiếu cho phép người dùng chỉ định các quy tắc cụ thể về ngôn ngữ để so sánh chuỗi, chẳng hạn như các quy tắc cho Lettercase và Dấu nhấn.

Tùy chọn đối chiếu có cú pháp sau:Use Variables in

{ : ,
...,
: }
1

Khi chỉ định đối chiếu, trường

collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
5 là bắt buộc; Tất cả các trường đối chiếu khác là tùy chọn. Để biết mô tả của các trường, xem tài liệu đối chiếu.

Việc loại bỏ tất cả các bộ sưu tập trong cơ sở dữ liệu cũng loại bỏ cơ sở dữ liệu?

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 returns an object that contains the status of the operation.

Returns:Một đối tượng Writeresult chứa trạng thái của hoạt động.WriteResult object that contains the status of the operation.

Phương thức

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 sử dụng lệnh
{ : ,
...,
: }
5, sử dụng mối quan tâm ghi mặc định. Để chỉ định một mối quan tâm ghi khác nhau, bao gồm mối quan tâm ghi trong tham số tùy chọn.
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
method uses the
{ : ,
...,
: }
5 command, which uses the default write concern. To specify a different write concern, include the write concern in the options parameter.

Theo mặc định,

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 xóa tất cả các tài liệu phù hợp với biểu thức
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
8. Chỉ định tùy chọn
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
7 để giới hạn hoạt động để xóa một tài liệu. Để xóa một tài liệu duy nhất được sắp xếp theo thứ tự được chỉ định, hãy sử dụng phương thức FindAndModify ().
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
removes all documents that match the
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
8 expression. Specify the
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
7 option to limit the operation to removing a single document. To delete a single document sorted by a specified order, use the findAndModify() method.

Khi xóa nhiều tài liệu, thao tác xóa có thể xen kẽ với các hoạt động đọc và/hoặc ghi khác vào bộ sưu tập.

Bạn không thể sử dụng phương pháp

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 với bộ sưu tập giới hạn.
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
method with a capped collection.

Bạn không thể sử dụng phương thức

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 trên bộ sưu tập chuỗi thời gian.
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
method on a time series collection.

Tất cả các hoạt động

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 cho bộ sưu tập Sharded chỉ định tùy chọn

db.products.remove( { qty: { $gt: 20 } } )

2 phải bao gồm khóa Shard hoặc trường

db.products.remove( { qty: { $gt: 20 } } )

3 trong đặc tả truy vấn.
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
operations for a sharded collection that specify the

db.products.remove( { qty: { $gt: 20 } } )

2 option must include the shard key or the

db.products.remove( { qty: { $gt: 20 } } )

3 field in the query specification.

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 Các hoạt động Chỉ định

db.products.remove( { qty: { $gt: 20 } } )

2 trong bộ sưu tập Sharded không chứa khóa Shard hoặc trường

db.products.remove( { qty: { $gt: 20 } } )

3 trả về lỗi. operations specifying

db.products.remove( { qty: { $gt: 20 } } )

2 in a sharded collection which do not contain either the shard key or the

db.products.remove( { qty: { $gt: 20 } } )

3 field return an error.

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
4 có thể được sử dụng bên trong các giao dịch đa tài liệu. can be used inside multi-document transactions.

Không đặt rõ ràng mối quan tâm ghi cho hoạt động nếu chạy trong một giao dịch. Để sử dụng viết mối quan tâm với các giao dịch, xem giao dịch và viết mối quan tâm.

Quan trọng

Trong hầu hết các trường hợp, giao dịch đa tài liệu phát sinh chi phí hiệu suất lớn hơn so với ghi tài liệu đơn lẻ và sự sẵn có của các giao dịch đa tài liệu không nên là một sự thay thế cho thiết kế lược đồ hiệu quả. Đối với nhiều kịch bản, mô hình dữ liệu được chuẩn hóa (tài liệu và mảng nhúng) sẽ tiếp tục tối ưu cho các trường hợp dữ liệu và sử dụng của bạn. Đó là, đối với nhiều kịch bản, mô hình hóa dữ liệu của bạn một cách thích hợp sẽ giảm thiểu nhu cầu cho các giao dịch đa tài liệu.

Để biết các cân nhắc sử dụng giao dịch bổ sung (như giới hạn thời gian chạy và giới hạn kích thước oplog), xem thêm các cân nhắc sản xuất.

Việc loại bỏ tất cả các bộ sưu tập trong cơ sở dữ liệu cũng loại bỏ cơ sở dữ liệu?

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 method.

Vâng, cho tất cả.

db.products.remove( { qty: { $gt: 20 } } )

9 method with an empty query document
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
9. The following operation deletes all documents from the bios collection:

Sau đây là các ví dụ về phương pháp

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6.

Để xóa tất cả các tài liệu trong một bộ sưu tập, hãy gọi phương thức

db.products.remove( { qty: { $gt: 20 } } )

9 bằng một tài liệu truy vấn trống
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
9. Hoạt động sau đây xóa tất cả các tài liệu khỏi bộ sưu tập BIOS:

Hoạt động này không tương đương với phương pháp

db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
1.
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
method with the
db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
4 parameter:

Để loại bỏ tất cả các tài liệu khỏi một bộ sưu tập, có thể hiệu quả hơn khi sử dụng phương thức

db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
1 để bỏ toàn bộ bộ sưu tập, bao gồm các chỉ mục, sau đó tạo lại bộ sưu tập và xây dựng lại các chỉ mục.

db.products.remove( { qty: { $gt: 20 } } )

Để xóa các tài liệu phù hợp với tiêu chí xóa, hãy gọi phương thức

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 với tham số
db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
4:

db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)

Hoạt động sau đây sẽ loại bỏ tất cả các tài liệu khỏi bộ sưu tập

db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
5 trong đó
db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
6 lớn hơn
db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
7:

db.products.remove( { qty: { $gt: 20 } } )

9
method with the
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
8 criteria and the
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
7 parameter set to
collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
1 or

db.products.remove( { qty: { $gt: 20 } }, true )

7.

Hoạt động sau đây cho một bộ bản sao sẽ loại bỏ tất cả các tài liệu khỏi bộ sưu tập

db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
5 trong đó
db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
6 lớn hơn
db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
7 và chỉ định mối quan tâm ghi của

db.products.remove( { qty: { $gt: 20 } }, true )

1 với

db.products.remove( { qty: { $gt: 20 } }, true )

2 của 5000 mili giây. Hoạt động này hoặc trở lại sau khi viết tuyên truyền cho cả chính và một phụ, hoặc hết lần sau 5 giây.

db.products.remove( { qty: { $gt: 20 } }, true )

Để xóa tài liệu đầu tiên phù hợp với tiêu chí xóa, hãy gọi phương thức

db.products.remove( { qty: { $gt: 20 } } )

9 với tiêu chí
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
8 và tham số
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
7 được đặt thành
collation: {
locale: ,
caseLevel: ,
caseFirst: ,
strength: ,
numericOrdering: ,
alternate: ,
maxVariable: ,
backwards:
}
1 hoặc

db.products.remove( { qty: { $gt: 20 } }, true )

7.

Hoạt động sau đây sẽ loại bỏ tài liệu đầu tiên khỏi bộ sưu tập

db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
5 trong đó
db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
6 lớn hơn
db.products.remove(
{ qty: { $gt: 20 } },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
7:

{ _id: 1, category: "café", status: "A" }
{ _id: 2, category: "cafe", status: "a" }
{ _id: 3, category: "cafE", status: "a" }

Đối chiếu cho phép người dùng chỉ định các quy tắc cụ thể về ngôn ngữ để so sánh chuỗi, chẳng hạn như các quy tắc cho Lettercase và Dấu nhấn.

db.myColl.remove(
{ category: "cafe", status: "A" },
{ collation: { locale: "fr", strength: 1 } }
)

Bộ sưu tập

{ _id: 1, category: "café", status: "A" }
{ _id: 2, category: "cafe", status: "a" }
{ _id: 3, category: "cafE", status: "a" }
1 có các tài liệu sau:

Hoạt động sau bao gồm tùy chọn đối chiếu:let option.

Mới trong phiên bản 5.0.

Để xác định các biến mà bạn có thể truy cập ở nơi khác trong lệnh, hãy sử dụng tùy chọn LET.

Tạo bộ sưu tập

{ _id: 1, category: "café", status: "A" }
{ _id: 2, category: "cafe", status: "a" }
{ _id: 3, category: "cafE", status: "a" }
3:

db.cakeFlavors.insertMany( [
{ _id: 1, flavor: "chocolate" },
{ _id: 2, flavor: "strawberry" },
{ _id: 3, flavor: "cherry" }
] )

Ví dụ sau đây xác định biến

{ _id: 1, category: "café", status: "A" }
{ _id: 2, category: "cafe", status: "a" }
{ _id: 3, category: "cafE", status: "a" }
4 trong
{ : ,
...,
: }
1 và sử dụng biến để xóa hương vị bánh dâu tây:

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
0

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 trả về một đối tượng
{ _id: 1, category: "café", status: "A" }
{ _id: 2, category: "cafe", status: "a" }
{ _id: 3, category: "cafE", status: "a" }
7 chứa trạng thái của hoạt động. Khi thành công, đối tượng
{ _id: 1, category: "café", status: "A" }
{ _id: 2, category: "cafe", status: "a" }
{ _id: 3, category: "cafE", status: "a" }
7 chứa thông tin về số lượng tài liệu bị xóa:
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
returns a
{ _id: 1, category: "café", status: "A" }
{ _id: 2, category: "cafe", status: "a" }
{ _id: 3, category: "cafE", status: "a" }
7 object that contains the status of the operation. Upon success, the
{ _id: 1, category: "café", status: "A" }
{ _id: 2, category: "cafe", status: "a" }
{ _id: 3, category: "cafE", status: "a" }
7 object contains information on the number of documents removed:

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
1

Mẹo

Xem thêm:

Nếu phương thức

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 gặp phải viết các lỗi liên quan, kết quả bao gồm trường
db.myColl.remove(
{ category: "cafe", status: "A" },
{ collation: { locale: "fr", strength: 1 } }
)
0:
db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6
method encounters write concern errors, the results include the
db.myColl.remove(
{ category: "cafe", status: "A" },
{ collation: { locale: "fr", strength: 1 } }
)
0 field:

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
2

Mẹo

Xem thêm:

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
6 method encounters a non-write concern error, the results include
db.myColl.remove(
{ category: "cafe", status: "A" },
{ collation: { locale: "fr", strength: 1 } }
)
2 field:

db.collection.remove(
,
{
justOne: ,
writeConcern: <document>,
collation: <document>,
let: <document> // Added in MongoDB 5.0
}
)
3

Mẹo

Xem thêm:

Truy vấn nào được sử dụng để loại bỏ một bộ sưu tập trong MongoDB?

Phương thức db.collection.remove () được sử dụng để loại bỏ các tài liệu khỏi bộ sưu tập.Chỉ định tiêu chí xóa bằng cách sử dụng các toán tử truy vấn.db. collection. remove() method is used to remove documents from a collection. Specifies deletion criteria using query operators.

Sự khác biệt giữa loại bỏ và xóa trong MongoDB là gì?

DeletMany: Lệnh trả về Boolean là đúng nếu thao tác chạy tốt với mối quan tâm ghi và trả về sai nếu chúng ta vô hiệu hóa mối quan tâm ghi.Ngoài ra, nó trả về DeletedCount có chứa số tài liệu đã xóa.Hủy bỏ: Lệnh trả về Writeresult.

Làm thế nào xóa dữ liệu khỏi MongoDB?

Shell MongoDB cung cấp các phương pháp sau để xóa tài liệu khỏi bộ sưu tập:..
Để xóa nhiều tài liệu, sử dụng DB.thu thập.Deletemany ().
Để xóa một tài liệu duy nhất, sử dụng DB.thu thập.Xóa ().

Việc loại bỏ tất cả các bộ sưu tập trong cơ sở dữ liệu cũng loại bỏ cơ sở dữ liệu?

Vâng, cho tất cả..