假設有個這樣的集合
<code>{ "_id" : ObjectId("5022518d09248743250688e0"), "name" : "big fruit", "fruits" : [ "apple", "pear", "orange" ] } , { "_id" : ObjectId("502251a309248743250688e1"), "name" : "good fruit", "fruits" : [ "banana", "pear", "orange" ] } , { "_id" : ObjectId("502251c109248743250688e2"), "name" : "good fruit", "fruits" : [ "banana", "apple", "tomato" ] } </code>
假設有這樣的集合
RT 者兩句代碼用PHP怎麼寫
<code>db.coll.find({_id:{$in[ ObjectId("502251a309248743250688e1"), ObjectId("502251c109248743250688e2")]}})</code>
查詢長度為三的陣列
<code>db.coll.find({fruits:{$size:0}})</code>
用PHP的話怎麼實現
假設有個這樣的集合
<code>{ "_id" : ObjectId("5022518d09248743250688e0"), "name" : "big fruit", "fruits" : [ "apple", "pear", "orange" ] } , { "_id" : ObjectId("502251a309248743250688e1"), "name" : "good fruit", "fruits" : [ "banana", "pear", "orange" ] } , { "_id" : ObjectId("502251c109248743250688e2"), "name" : "good fruit", "fruits" : [ "banana", "apple", "tomato" ] } </code>
假設有這樣的集合
RT 者兩句代碼用PHP怎麼寫
<code>db.coll.find({_id:{$in[ ObjectId("502251a309248743250688e1"), ObjectId("502251c109248743250688e2")]}})</code>
查詢長度為三的陣列
<code>db.coll.find({fruits:{$size:0}})</code>
用PHP的話怎麼實現