MongoDBの明確なクエリについてはどうやって説明しますか?MongoDBの明確なクエリをどう説明しますか?
db.test3.distinct("id", { key:"value"}).explain()
エラー:
explain is not a function (shell)
MongoDBの明確なクエリについてはどうやって説明しますか?MongoDBの明確なクエリをどう説明しますか?
db.test3.distinct("id", { key:"value"}).explain()
エラー:
explain is not a function (shell)
あなたはこのMongoDBのjira ticketごとなどの個別に説明使用することはできません。代わりに、
db.runCommand({ distinct: 'test3',key:'id',query:{key:"value"}})
は、上記のクエリのTEST3でexplain()
runCommand
を使用して統計情報を確認することができ、あなたがいずれかを指定したい場合は、キーを使用すると、最終的にははっきりとし適用するフィールド名で、コレクション名ですフィルタはクエリを使用します。
確認サンプル、あなたが行うことができますモンゴ3.2のよう
> db.runCommand({ distinct: 'items',key:'name',query:{offered:true}})
{
"values" : [
"test flat",
"Another aston martin",
"super luxury villa",
"Aston martin vanquish y for sale",
"Super car",
"Test item",
"another sports car",
"super car"
],
"stats" : {
"n" : 8,
"nscanned" : 10,
"nscannedObjects" : 10,
"timems" : 45,
"cursor" : "BasicCursor"
},
"ok" : 1
}
> db.runCommand({ distinct: 'items',key:'name',query:{offered:false}})
{
"values" : [
"yamaha",
"Test item"
],
"stats" : {
"n" : 2,
"nscanned" : 10,
"nscannedObjects" : 10,
"timems" : 0,
"cursor" : "BasicCursor"
},
"ok" : 1
}
:
db.test3.explain().distinct("id", {key: "value"})
https://docs.mongodb.org/manual/reference/method/db.collection.explain/
ありがとう!これは私にとって素晴らしい作品です。 –
私は統計を見ることができません、私はちょうど戻って値を取得し、応答としてok。 – genericuser
@ RyanHoffman:承認された回答としてマークする必要があります.IMHO。ありがとう! –