db.foo.find();
_id | type
-------------
10001 1
10002 'a'
10003 [1, 2, 3, 4]
ご存知のように、$typeは次のように mongo クエリの型コードと一致します。
db.foo.find({type: {$type: 4}});
_id | タイプ
----------
10003、[1、2、3、4]
次に、 test.jsという JavaScript シェル スクリプトを作成します。
var curs = db.foo.find();
curs.forEach(showTypeCode);
function showTypeCode(cur) {
print(cur.type + '-' + typeof(cur.type));
};
結果:
1-number
a-string
1,2,3,4-object (this is an array, it's 4 in mongo)
これが私の質問です。mongoシェルで配列型コードを取得するにはどうすればよいですか