MongoDB ids can be anything

Even an object! Bananatown.

> db.x.insert({‘_id’: {‘a’: 123, ‘b’: 456} })

> db.x.find({‘_id’: { $lte: {‘a’: 124 } } })      { “_id” : { “a” : 123, “b” : 456 } }

(Caveat, keys have to be in same order. For example, in Python, construct your ids using http://api.mongodb.org/python/1.9%2B/api/bson/son.html)

blog comments powered by Disqus

Notes

  1. codeshal posted this