Đây là trường hợp khi chúng ta có hai hoặc nhiều điều kiện và kết quả là chúng ta nhận được các tài liệu trong đó một phần tử của mảng khớp với một điều kiện và một tài liệu khác chỉ khớp với điều kiện kia
Tất nhiên, điều chúng ta muốn là một phần tử của mảng khớp với cả hai điều kiện cùng một lúc
Trong hướng dẫn này, chúng ta sẽ tìm hiểu cách chỉ chọn những tài liệu trong tập dữ liệu có chứa các trường trong mảng đáp ứng yêu cầu của chúng ta và chỉ chiếu các trường của mảng mà chúng ta cần
Ứng dụng khách MongoDB Studio 3T cung cấp nhiều cách để truy vấn các mảng MongoDB
Hướng dẫn này bao gồm cách lọc các phần tử bằng cách sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6 cùng với
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]7, các giai đoạn tổng hợp MongoDB
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]8 và
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]9, và IntelliShell, vỏ mongo tích hợp sẵn của Studio 3T
Nếu bạn thích cách tiếp cận trực quan, không mã, thì đây là hướng dẫn về cách truy vấn các giá trị chuỗi và phần tử mảng bằng cách sử dụng trình tạo truy vấn kéo và thả
Trong bài đăng này, tập dữ liệu mà chúng ta sẽ làm việc chỉ bao gồm một tập hợp các mục có tên là
BulkWriteResult[{
"writeErrors" : [ ],
"writeConcernErrors" : [ ],
"nInserted" : 2,
"nUpserted" : 0,
"nMatched" : 0,
"nModified" : 0,
"nRemoved" : 0,
"upserted" : [ ]
}]
0 và hai tài liệu – đủ cho mục đích giáo khoa của chúng taNhư đã quen thuộc trong các bài viết trước của tôi, cơ sở dữ liệu mà chúng ta sẽ sử dụng có tên là
BulkWriteResult[{
"writeErrors" : [ ],
"writeConcernErrors" : [ ],
"nInserted" : 2,
"nUpserted" : 0,
"nMatched" : 0,
"nModified" : 0,
"nRemoved" : 0,
"upserted" : [ ]
}]
1Thông tin chúng tôi có trong mỗi tài liệu là
2 – Mã của bài viếtBulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]
3 – Mô tả bài viếtBulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]
4 – Mảng với thông tin liên quan đến các giao dịch mua được thực hiện cho các nhà cung cấp của chúng tôiBulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]
5 – Mảng với thông tin liên quan đến hàng tồn kho trên mỗi quốc gia và kho hàngBulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]
Chúng ta sẽ sử dụng IntelliShell, mongo shell tích hợp sẵn trong Studio 3T, xuyên suốt hướng dẫn. Hãy sử dụng nó để thêm hai tài liệu mới của chúng tôi
1.
2.
3. Mở IntelliShell, thực hiện nhanh nhất bằng phím tắt Ctrl + L [⌘+ L]
Nhận IntelliShell trong phiên bản Studio 3T mới nhất
4. Thực hiện truy vấn này trong cơ sở dữ liệu
BulkWriteResult[{
"writeErrors" : [ ],
"writeConcernErrors" : [ ],
"nInserted" : 2,
"nUpserted" : 0,
"nMatched" : 0,
"nModified" : 0,
"nRemoved" : 0,
"upserted" : [ ]
}]
1 của chúng tôi để lưu trữ hai tài liệu này trong bộ sưu tập BulkWriteResult[{
"writeErrors" : [ ],
"writeConcernErrors" : [ ],
"nInserted" : 2,
"nUpserted" : 0,
"nMatched" : 0,
"nModified" : 0,
"nRemoved" : 0,
"upserted" : [ ]
}]
0 của chúng tôiBulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]2
5. Trong tab Kết quả, chọn Chế độ xem JSON. Kết quả phải là
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]
BulkWriteResult[{
"writeErrors" : [ ],
"writeConcernErrors" : [ ],
"nInserted" : 2,
"nUpserted" : 0,
"nMatched" : 0,
"nModified" : 0,
"nRemoved" : 0,
"upserted" : [ ]
}]
Bây giờ chúng tôi đã chèn hai tài liệu, giả sử chúng tôi muốn lấy những mặt hàng đó cùng với kho hàng trong kho
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]50 của quốc gia
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]51
Nếu chúng tôi không có kinh nghiệm cần thiết, lần thử đầu tiên của chúng tôi sẽ giống như thế này
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]5
Điều này mang lại cho chúng tôi kết quả này trong Chế độ xem JSON
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]8
lưu ý bên lề. Rất dễ dàng để xây dựng các truy vấn
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]7 như vậy bằng cách sử dụng Trình tạo truy vấn trực quan trong Studio 3T
đọc liên quan. Trình tạo truy vấn trực quan, trình tạo truy vấn MongoDB kéo và thả của Studio 3T
Trong ảnh chụp màn hình ở trên, chúng tôi chỉ cần kéo các trường vào trình tạo truy vấn, xác định các giá trị và chạy truy vấn
Truy vấn trả về hai tài liệu giống nhau, được dán lại toàn bộ bên dưới
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]0
Nếu chúng tôi xem xét kỹ tài liệu trong đó trường
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]53 bằng với
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]54 [được in đậm ở trên] thì các yêu cầu của chúng tôi được đáp ứng trong một trong các tài liệu con của mảng
Trong tài liệu mà trường
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]53 bằng với
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]56 [cũng được in đậm ở trên], chỉ có một điều kiện được khớp trong mỗi tài liệu con của mảng
Mục đích của chúng tôi là chỉ lấy những tài liệu trong đó tất cả các điều kiện của chúng tôi được đáp ứng, đồng thời, trong tài liệu phụ hoặc tài liệu phụ của mảng
Điều đó có nghĩa là truy vấn này sẽ không trả về tài liệu mà trường
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]53 bằng với
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]56
Để xây dựng truy vấn này một cách thích hợp, chúng ta phải sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6
Tài liệu MongoDB chính thức cho phiên bản 4. 0 tiểu bang
Toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6 khớp với các tài liệu chứa trường mảng có ít nhất một phần tử khớp với tất cả các tiêu chí truy vấn đã chỉ định
Đây là cú pháp của toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]0
Chúng ta có thể sử dụng
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6 trong phần truy vấn của hàm
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]7 và/hoặc trong phần phép chiếu của nó
Hãy quay lại IntelliShell và chạy truy vấn này
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]3
Điều này sẽ cung cấp cho bạn kết quả
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]4
Như chúng ta mong đợi, truy vấn đã trả về đúng tài liệu [trong đó trường
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]53 bằng với
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]54]
Tiếp theo, chúng ta sẽ tìm hiểu cách chỉ lọc ra khỏi mảng những phần tử đáp ứng tiêu chí của chúng ta bằng cách sử dụng giai đoạn tổng hợp,
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]9
Để viết truy vấn tổng hợp dễ dàng hơn, chúng tôi sẽ sử dụng Trình chỉnh sửa tổng hợp của Studio 3T
Hãy bắt đầu bằng cách lấy truy vấn ban đầu của chúng tôi và chỉ sao chép phần được in đậm
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]8
Mở Aggregation Editor trong Studio 3T, thực hiện nhanh nhất bằng phím tắt F4
Thêm giai đoạn đầu tiên bằng cách sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]8 và dán phần in đậm của truy vấn. Đảm bảo bạn xóa mọi dấu ngoặc giữ chỗ hiện có nếu không bạn có thể gặp lỗi
Thực hiện đường ống. Kết quả sẽ giống như ảnh chụp màn hình bên dưới, trong Chế độ xem JSON
đọc liên quan. Aggregation Editor, trình xây dựng đường dẫn tổng hợp MongoDB theo từng giai đoạn của Studio 3T
Trong một số trường hợp, chúng tôi không muốn chiếu [hoặc hiển thị] tất cả các trường trong tài liệu mà chỉ những trường phù hợp với yêu cầu của chúng tôi
Đối với điều này, chúng ta chỉ cần lọc ra khỏi mảng những phần tử đáp ứng tiêu chí của chúng ta. Chúng tôi có thể làm điều này bằng cách sử dụng giai đoạn tổng hợp
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]9
Để đạt được mục tiêu của chúng tôi – lọc tài liệu để chỉ hiển thị các trường chúng tôi cần – chúng tôi phải sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]89 cùng với khung tổng hợp
Hãy tiếp tục với ví dụ tương tự
Chúng tôi duy trì giai đoạn
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]8 để chỉ lấy tài liệu chúng tôi cần và sau đó chúng tôi thêm giai đoạn
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]9
Trong giai đoạn này, chúng tôi chiếu tất cả các trường chúng tôi cần và thông qua toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]89, chúng tôi cho cơ sở dữ liệu biết những trường nào bên trong mảng mà chúng tôi cũng muốn chiếu
Toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]89 có ba biến
- đầu vào. mảng chúng ta sẽ làm việc với
- như. tên tham khảo
- điều kiện. yêu cầu của chúng tôi
Ngay bây giờ, đây là giao diện đầy đủ của truy vấn của chúng tôi. Hãy sao chép, dán và chạy truy vấn trong IntelliShell
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]0
Sau đó, hãy kiểm tra xem đầu ra có đáp ứng những gì chúng ta đang tìm kiếm không
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]1
Được rồi, chúng tôi hiểu rồi
Bây giờ quay lại Trình chỉnh sửa tổng hợp
Hãy thêm giai đoạn thứ hai bằng cách sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]9 và dán truy vấn bên dưới. Đảm bảo bạn xóa mọi dấu ngoặc giữ chỗ hiện có nếu không bạn có thể gặp lỗi
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]2
Tiếp theo, thực hiện toàn bộ quy trình. Bạn chỉ nên xem một tài liệu
Có lẽ bạn đang tự hỏi. Tại sao chúng ta không sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6 trong phần chiếu của
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]7, thay vì sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]89 trong khung tổng hợp?
Hãy tham khảo tài liệu chính thức
Toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6 chiếu phần tử phù hợp đầu tiên từ một mảng dựa trên một điều kiện
VÂNG. Để hiểu rõ hơn điều này có nghĩa là gì, chúng tôi sẽ chèn một tài liệu mới vào bộ sưu tập
BulkWriteResult[{
"writeErrors" : [ ],
"writeConcernErrors" : [ ],
"nInserted" : 2,
"nUpserted" : 0,
"nMatched" : 0,
"nModified" : 0,
"nRemoved" : 0,
"upserted" : [ ]
}]
0 của chúng tôiQuay lại IntelliShell và chạy truy vấn bên dưới để chèn tài liệu thứ ba của chúng tôi
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]3
Tiếp theo, hãy chạy truy vấn này bằng cách sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6 trong phần chiếu của hàm
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]7
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]4
Đây là tài liệu truy vấn trả về
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]5
Vì vậy, đây không phải là những gì chúng tôi đang tìm kiếm và đây là lý do chúng tôi không sử dụng nó
Chúng ta đã học cách giải quyết một trong những vấn đề phổ biến nhất thường gây khó khăn cho những người mới sử dụng MongoDB, đó là cách truy vấn một mảng khi phải đáp ứng nhiều hơn một điều kiện trong cùng một phần tử
Bây giờ chúng ta cũng biết cách sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]6
Khi chúng tôi đã đạt được mục tiêu đầu tiên của mình, mục tiêu thứ hai là chỉ trích xuất từ mảng các phần tử chúng tôi cần. Bây giờ chúng ta đã biết và có thể sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]89 cùng với khung tổng hợp
Cuối cùng, chúng ta đã học về cách sử dụng toán tử
BulkWriteResult[{ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }]8 trong phần dự án của hàm tìm
Tìm thêm các bài tập để thực hành kỹ năng lọc mảng của bạn trong khóa học MongoDB của chúng tôi, MongoDB 201. Truy vấn dữ liệu MongoDB. Lặn thẳng vào, không cần đăng ký