Reputation: 35346
I need to provide a way that my mongodb server will store each document id as long integer (64-bit) starting from 0 and increment as document is inserted.
Here's a kind of document I need to insert:
{
"_id" : "0",
"name" : "John Smith"
}
At some point in my code I need to get the id as Java type long
integer and do some stuff on it. How do I get it as type long. Without using object mapping like Morphia, etc.
Upvotes: 0
Views: 223
Reputation: 11052
MongoDB doesn't know additional stuff like long, signed, unsigned, etc.
You just can save it as an integer. But you always should save your document ID as an ObjectID, since MongoDB takes care of the unique ID itself.
Upvotes: 1