4 ms·
One neat thing about Mongo is the ObjectID's: We didn't know it at the time, but you can get the date of creation from them. Which means... If you sort by Obje
by giancarlostoro 4y ago
One neat thing about Mongo is the ObjectID's:
We didn't know it at the time, but you can get the date of creation from them. Which means... If you sort by ObjectID, you're actually sorting by creation time. You can create a generic ObjectID using JavaScript and filter by time ranges. I still have a codepen proof of concept I did for doing ranges.
Anyway, the other thing is, and I'm not sure how many people use it this way: you can copy an ObjectID verbatim into other documents, like a foreign key, so you can reference between collections. If you do this, you'll save yourself a lot of headaches. Just because you can shove anything and everything into MongoDB documents, doesn't mean you absolutely should.