Tôi đang sử dụng la bàn MongoDB và không có vỏ Mongo. Tôi cần xây dựng một truy vấn bằng công cụ la bàn MongoDB để chọn các giá trị riêng biệt của trường "thể loại" từ bộ sưu tập của tôi.
Đầu vào mẫu:
{"_id":{"$oid":"58c59c6a99d4ee0af9e0c34e"},"title":"Bateau-mouche sur la Seine","year":{"$numberInt":"1896"},"imdbId":"tt0000042","genre":["Documentary”,”Short”],"viewerRating":{"$numberDouble":"3.8"},"viewerVotes":{"$numberInt":"17"},"director":"Georges Mlis"} {"_id":{"$oid":"58c59c6a99d4ee0af9e0c340"},"title":"Watering the Flowers","year":{"$numberInt":"1896"},"imdbId":"tt0000035","genre":["Short”],"viewerRating":{"$numberDouble":"5.3"},"viewerVotes":{"$numberInt":"33"},"director":"Georges M�li�s"} {"_id":{"$oid":"58c59c6a99d4ee0af9e0c34a"},"title":"The Boxing Kangaroo","year":{"$numberInt":"1896"},"imdbId":"tt0000048","genre":["Short”],"viewerRating":{"$numberDouble":"5.2"},"viewerVotes":{"$numberInt":"48"},"director":"Birt Acres"}Đầu ra mong đợi: phim tài liệu, ngắn: Documentary, Short
Tài liệu về nhà → Hướng dẫn sử dụng MongoDB → MongoDB Manual
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Finds the
distinct values for a specified field across a single collection.
9 returns a document that contains an array of the distinct values. The return document also contains an embedded document with query statistics and the query plan.db.runCommand( { distinct: "<collection>", key: "<field>", query: <query>, readConcern: <read concern document>, collation: <collation document>, comment: <any> } )
Mẹo
Trong
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
Các phương thức trợ giúp thuận tiện cho người dùng
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
Lệnh có cú pháp sau:
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Lệnh lấy các trường sau:
| sợi dây | Tên của bộ sưu tập để truy vấn cho các giá trị riêng biệt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sợi dây | Tên của bộ sưu tập để truy vấn cho các giá trị riêng biệt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Trường để trả về các giá trị riêng biệt. | tài liệu | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Trường để trả về các giá trị riêng biệt. | tài liệu Không bắt buộc. Một truy vấn chỉ định các tài liệu để lấy các giá trị riêng biệt. Không bắt buộc. Chỉ định mối quan tâm đọc.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Trường để trả về các giá trị riêng biệt. | Optional. tài liệu Không bắt buộc. Một truy vấn chỉ định các tài liệu để lấy các giá trị riêng biệt. Không bắt buộc. Chỉ định mối quan tâm đọc.
Bắt đầu từ MongoDB 3.6, tùy chọn ReadConcern có cú pháp sau:
Có thể đọc các cấp độ quan tâm là:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| không tí nào | Optional. Một nhận xét do người dùng cung cấp để đính kèm vào lệnh này. Sau khi được đặt, nhận xét này xuất hiện cùng với các bản ghi của lệnh này ở các vị trí sau:
Một nhận xét có thể là bất kỳ loại BSON hợp lệ (chuỗi, số nguyên, đối tượng, mảng, v.v.). Mới trong phiên bản 4.4. |
Ghi chú
MongoDB cũng cung cấp phương thức trình bao bọc shell
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Trong một cụm bị che khuất, lệnh
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Nếu giá trị của
db.runCommand ( { distinct: "inventory", key: "dept" } )
7 được chỉ định là một mảng,db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Chẳng hạn, nếu một trường có giá trị của nó
db.runCommand ( { distinct: "inventory", key: "dept" } )
9, thìdb.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
{ |
"values" : [ "A", "B" ], |
"ok" : 1 |
} |
{ |
"values" : [ "A", "B" ], |
"ok" : 1 |
} |
{ |
"values" : [ "A", "B" ], |
"ok" : 1 |
} |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
{ |
"values" : [ "A", "B" ], |
"ok" : 1 |
} |
{ |
"values" : [ "A", "B" ], |
"ok" : 1 |
} |
{ |
"values" : [ "A", "B" ], |
"ok" : 1 |
} |
Bắt đầu từ MongoDB 6.0, lệnh
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Để biết ví dụ, xem:
Trả về các giá trị riêng biệt cho một trường mảng
Mảng trong bộ sưu tập và chế độ xem
Khi có thể, các hoạt động
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Các chỉ mục cũng có thể bao gồm các hoạt động
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Để thực hiện một hoạt động khác biệt trong một giao dịch:
Đối với các bộ sưu tập không có vỏ, bạn có thể sử dụng phương thức
2/lệnhcollation: { locale: <string>, caseLevel: <boolean>, caseFirst: <string>, strength: <int>, numericOrdering: <boolean>, alternate: <string>, maxVariable: <string>, backwards: <boolean> }
9 cũng như đường ống tổng hợp với giai đoạndb.runCommand( { distinct: "<collection>", key: "<field>", query: <query>, readConcern: <read concern document>, collation: <collation document>, comment: <any> } )
9.{ "values" : [ "A", "B" ], "ok" : 1 }
9 command as well as the aggregation pipeline with thedb.runCommand( { distinct: "<collection>", key: "<field>", query: <query>, readConcern: <read concern document>, collation: <collation document>, comment: <any> } )
9 stage.{ "values" : [ "A", "B" ], "ok" : 1 } Đối với các bộ sưu tập Sharded, bạn không thể sử dụng phương thức
2 hoặc lệnhcollation: { locale: <string>, caseLevel: <boolean>, caseFirst: <string>, strength: <int>, numericOrdering: <boolean>, alternate: <string>, maxVariable: <string>, backwards: <boolean> }
9.db.runCommand( { distinct: "<collection>", key: "<field>", query: <query>, readConcern: <read concern document>, collation: <collation document>, comment: <any> } )
9 command.db.runCommand( { distinct: "<collection>", key: "<field>", query: <query>, readConcern: <read concern document>, collation: <collation document>, comment: <any> } ) Để tìm các giá trị riêng biệt cho một bộ sưu tập Sharded, hãy sử dụng đường ống tổng hợp với giai đoạn
9 thay thế. Xem hoạt động khác biệt để biết chi tiết.{ "values" : [ "A", "B" ], "ok" : 1 }
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.
Bắt đầu từ MongoDB 4.2, nếu khách hàng phát hành
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand ( { distinct: "inventory", key: "item.sku" } )
5db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand ( { distinct: "inventory", key: "item.sku" } )
5Bắt đầu từ MongoDB 4.4, để chạy trên một thành viên tập hợp, các hoạt động
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand ( { distinct: "inventory", key: "item.sku" } )
7 hoặcdb.runCommand ( { distinct: "inventory", key: "item.sku" } )
8. Nếu thành viên ở một trạng thái khác, chẳng hạn nhưdb.runCommand ( { distinct: "inventory", key: "item.sku" } )
9, các lỗi hoạt động.db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand ( { distinct: "inventory", key: "item.sku" } )
7 ordb.runCommand ( { distinct: "inventory", key: "item.sku" } )
8 state. If the member is in another state, such asdb.runCommand ( { distinct: "inventory", key: "item.sku" } )
9, the operation errors.Trong các phiên bản trước, các hoạt động cũng chạy khi thành viên ở
db.runCommand ( { distinct: "inventory", key: "item.sku" } )
9. Các hoạt động đợi cho đến khi thành viên chuyển sang{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
Bắt đầu từ MongoDB 6.0, bộ lọc chỉ mục sử dụng bộ đối chiếu được đặt trước đó bằng lệnh
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
Các ví dụ sử dụng bộ sưu tập
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ "_id": 1, "dept": "A", "item": { "sku": "111", "color": "red" }, "sizes": [ "S", "M" ] } |
{ "_id": 2, "dept": "A", "item": { "sku": "111", "color": "blue" }, "sizes": [ "M", "L" ] } |
{ "_id": 3, "dept": "B", "item": { "sku": "222", "color": "blue" }, "sizes": "S" } |
{ "_id": 4, "dept": "A", "item": { "sku": "333", "color": "black" }, "sizes": [ "S" ] } |
Ví dụ sau trả về các giá trị riêng biệt cho trường
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
db.runCommand ( { distinct: "inventory", key: "dept" } )
Lệnh trả về một tài liệu với một trường có tên
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "A", "B" ], |
"ok" : 1 |
} |
Ví dụ sau trả về các giá trị riêng biệt cho trường
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
db.runCommand ( { distinct: "inventory", key: "item.sku" } )
Lệnh trả về một tài liệu với một trường có tên
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
Mẹo
Xem thêm:
Ký hiệu chấm cho thông tin về truy cập các trường trong các tài liệu nhúng
Ví dụ sau trả về các giá trị riêng biệt cho trường
db.runCommand ( { distinct: "inventory", key: "sizes" } )
3 từ tất cả các tài liệu trong bộ sưu tập{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
db.runCommand ( { distinct: "inventory", key: "sizes" } )
Lệnh trả về một tài liệu với một trường có tên
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
db.runCommand ( { distinct: "inventory", key: "sizes" } )
3 riêng biệt:{ |
"values" : [ "M", "S", "L" ], |
"ok" : 1 |
} |
Để biết thông tin về các trường
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Bắt đầu từ MongoDB 6.0, lệnh
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Để biết ví dụ, xem:
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Trả về các giá trị riêng biệt cho một trường mảng
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Mảng trong bộ sưu tập và chế độ xem
9 to return the unique values from the db.runCommand( { distinct: "<collection>", key: "<field>", query: <query>, readConcern: <read concern document>, collation: <collation document>, comment: <any> } )
{ |
"values" : [ "M", "S", "L" ], |
"ok" : 1 |
} |
db.runCommand ( { distinct: "inventory", key: "sizes" } )
9 collection:db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Khi có thể, các hoạt động
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Ví dụ đầu ra:
Ví dụ cho
{ |
"values" : [ "M", "S", "L" ], |
"ok" : 1 |
} |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Ví dụ đầu ra:
9 bắt đầu từ MongoDB 6.0 (giống hệt kết quả được trả về từ bộ sưu tập{ "values" : [ "M", "S", "L" ], "ok" : 1 } db.runCommand ( { distinct: "inventory", key: "sizes" } )
9).
01 trong phiên bản MongoDB sớm hơn 6.0.db.runCommand( { distinct: "<collection>", key: "<field>", query: <query>, readConcern: <read concern document>, collation: <collation document>, comment: <any> } )
Ví dụ sau trả về các giá trị riêng biệt cho trường
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Lệnh trả về một tài liệu với một trường có tên
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
{ |
"values" : [ "111", "222", "333" ], |
"ok" : 1 |
} |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Đố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.
Bộ sưu tập
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Hoạt động tổng hợp sau đây bao gồm tùy chọn đối chiếu:
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Để biết mô tả về các trường đối chiếu, xem tài liệu đối chiếu.
Để ghi đè lên mức độ liên quan đọc mặc định của
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
collation: { |
locale: <string>, |
caseLevel: <boolean>, |
caseFirst: <string>, |
strength: <int>, |
numericOrdering: <boolean>, |
alternate: <string>, |
maxVariable: <string>, |
backwards: <boolean> |
} |
Hoạt động sau đây trên một bộ bản sao chỉ định mối quan tâm đọc của
{ "_id": 1, "dept": "A", "item": { "sku": "111", "color": "red" }, "sizes": [ "S", "M" ] } |
{ "_id": 2, "dept": "A", "item": { "sku": "111", "color": "blue" }, "sizes": [ "M", "L" ] } |
{ "_id": 3, "dept": "B", "item": { "sku": "222", "color": "blue" }, "sizes": "S" } |
{ "_id": 4, "dept": "A", "item": { "sku": "333", "color": "black" }, "sizes": [ "S" ] } |
Ghi chú
Bất kể mức độ quan tâm đọc, dữ liệu gần đây nhất trên một nút có thể không phản ánh phiên bản gần đây nhất của dữ liệu trong hệ thống.
db.runCommand( |
{ |
distinct: "<collection>", |
key: "<field>", |
query: <query>, |
readConcern: <read concern document>, |
collation: <collation document>, |
comment: <any> |
} |
) |
Để đảm bảo rằng một luồng duy nhất có thể đọc các chữ viết của riêng mình, hãy sử dụng
{ "_id": 1, "dept": "A", "item": { "sku": "111", "color": "red" }, "sizes": [ "S", "M" ] } |
{ "_id": 2, "dept": "A", "item": { "sku": "111", "color": "blue" }, "sizes": [ "M", "L" ] } |
{ "_id": 3, "dept": "B", "item": { "sku": "222", "color": "blue" }, "sizes": "S" } |
{ "_id": 4, "dept": "A", "item": { "sku": "333", "color": "black" }, "sizes": [ "S" ] } |
{ "_id": 1, "dept": "A", "item": { "sku": "111", "color": "red" }, "sizes": [ "S", "M" ] } |
{ "_id": 2, "dept": "A", "item": { "sku": "111", "color": "blue" }, "sizes": [ "M", "L" ] } |
{ "_id": 3, "dept": "B", "item": { "sku": "222", "color": "blue" }, "sizes": "S" } |
{ "_id": 4, "dept": "A", "item": { "sku": "333", "color": "black" }, "sizes": [ "S" ] } |