MongoDBのindexなんだけど、valueのとこにnumberlong(1)とただの1が混じってて、なんだこれって調べてみたところ、
ドライバの仕様によっては1じゃなくてNumberLong(1)を使うものがあるが、インデックスの結果に影響はない
Some drivers may specify indexes, using NumberLong(1) rather than 1 as the specification. This does not have any affect on the resulting index.
ってことらしい。で、なんでそんなことになってるんかと調べてみたが、
- Javascriptで数値は64bitの浮動小数点型で表現される
- Javascript(とjson)は64bitの整数型がない
Why doesn’t Mongo output proper JSON? Why does NumberLong() etc exist?
The Javascript numbers are represented by the data type Number which a 64-bit floating point type, and Javascript (and JSON) doesn’t have any 64-bit integer data types.
あたりなのかなぁ...う~ん...
ところで、db.hoge.createIndex()はnumberlong(1)を受け付けないっぽい。
なんだこれ...