1
我在蒙戈以下集合:
> db.styles.find({ "_id" : "EP01L"}).pretty();
{
"_id" : "EP01L",
"__v" : 5,
"categoryIds" : [
ObjectId("5550dcc7a14c976741483c89"),
ObjectId("5550dcc7a14c976741483c8d")
],
"collectionId" : ObjectId("5550dab4a14c9766418ff2af"),
"colours" : {
"WH" : [
{
"on_sale" : false,
"size_code_id" : "S",
"sku" : "EP01L-WH1"
},
],
"BL" : [
{
"on_sale" : false,
"size_code_id" : "S",
"sku" : "EP01L-BL1"
},
]
},
"fabric" : {
"material" : [
{
"_id" : ObjectId("5550dab4a14c9766418ff2c4"),
"value" : 100
}
],
"type" : ObjectId("5550dab4a14c9766418ff2d1"),
"weight" : {
"ounce" : {
"min" : 4
},
"gram" : {
"min" : 155
}
}
},
"name" : {
"es-ES" : "CAMISETA MANGA LARGA HOMBRE",
"it-IT" : "T-SHIRT UOMO MANICA LUNGA",
"en-UK" : "MEN’S LONG SLEEVE T-SHIRT",
"fr-FR" : "T-SHIRT HOMME MANCHES LONGUES"
},
}
和
> db.attributes.find({"name.en-UK": "Fabric"}).pretty();
{
"_id" : ObjectId("5550dab4a14c9766418ff2dc"),
"values" : {
"source" : [
{
"code" : 1,
"_id" : ObjectId("5550dab4a14c9766418ff2bf"),
"name" : {
"fr-FR" : "Coton",
"it-IT" : "Cotone",
"en-UK" : "Cotton",
"es-ES" : "Algodón"
}
},
{
"code" : 2,
"_id" : ObjectId("5550dab4a14c9766418ff2c0"),
"name" : {
"fr-FR" : "Viscose",
"it-IT" : "Viscosa",
"en-UK" : "Viscose",
"es-ES" : "Viscosa"
}
},
],
"name" : [
{
"_id" : ObjectId("5550dab4a14c9766418ff2cd"),
"name" : {
"en-UK" : "3-ply Loopback"
}
},
{
"_id" : ObjectId("5550dab4a14c9766418ff2db"),
"name" : {
"en-UK" : "Woven Twill"
}
}
]
},
"name" : {
"en-UK" : "Fabric"
}
}
我想寫一個查詢,發現所有的風格文檔,其中面料.source是棉花或粘膠纖維,fabric.name是梭織斜紋布。
此查詢給了我所有具有fabric.type文件是棉或粘膠
> db.styles.find({ "fabric.type": { $in: [ ObjectId("5550dab4a14c9766418ff2cd"), ObjectId("5550dab4a14c9766418ff2db") ] } }).count();
3
>
但我怎麼找都在size_code_id是S
的款式和顏色的WH
?
大加讚賞
感謝,但我怎麼有多種顏色,例如,所有WH和BL? – khinester
我編輯了我的帖子,請檢查它。 –
很好,謝謝 – khinester