Is a leading underscore allowed for MongoDB field names?

2,055 views
Skip to first unread message

Max Weber

unread,
Jul 3, 2011, 9:13:18 AM7/3/11
to mongodb-user
Hello everyone,

I seem to recall that a leading underscore is not allowed for MongoDB
field names? I mean I've read about it in the MongoDB documentation
some time ago, but I can not find the relevant documentation section
anymore. For sure _id is reserved field name, but are all field names
with a leading underscore reserved for internal MongoDB fields? And
can I use my own ids for the _id field (for example UUIDs)?

Best regards

Max

Sam Millman

unread,
Jul 3, 2011, 9:17:11 AM7/3/11
to mongod...@googlegroups.com
I have never heard of _ prifxed fields being reserved except _id but if they were they are not anymore.

You can use whatever id you want for your document so long as you manage it. The default _id is only provided for ease really (default key).

To over write it just do an insert with _id and it will over write the default of that _id.


--
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.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


axlfu

unread,
Jul 3, 2011, 7:56:12 PM7/3/11
to mongodb-user
It is allowed
What's your mongoDB version?

Max Weber

unread,
Jul 5, 2011, 3:04:10 AM7/5/11
to mongodb-user
Thank you for the answers. It is a new project, so I will use the
latest stable version of MongoDB.

Best regards

Max
Reply all
Reply to author
Forward
0 new messages