By default the _id field has a unique index and can be considered the
primary key in the way you are probably thinking about it.
You can do this:
db.demo.insert({ "_id" : 1 , "username" : "hendry" })
If you leave out the _id field then one will be generated for you as
an ObjectId:
http://www.mongodb.org/display/DOCS/Object+IDs
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to
mongod...@googlegroups.com
> To unsubscribe from this group, send email to
>
mongodb-user...@googlegroups.com
> See also the IRC channel --
freenode.net#mongodb