Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What characters are NOT allowed in MongoDB field names?

Tags:

mongodb

I figured out that of course . and SPACE aren't allowed. Are there other forbidden characters ?

like image 503
Blacksad Avatar asked Mar 18 '12 16:03

Blacksad


People also ask

Can MongoDB store special characters?

ASP.NET Core 3 MVC Application with MongoDBTo search a string with special characters in MongoDB document, you can use \. Here, we have special character $ in our string.

Are MongoDB field names case sensitive?

Database names and Collection names are case sensitive. You can always recreate the DB/Collection with the appropriate name. The Mongo Shell is a interactive JS interpreter.

What is field name in MongoDB?

Field names are strings. Documents have the following restrictions on field names: The field name _id is reserved for use as a primary key; its value must be unique in the collection, is immutable, and may be of any type other than an array.

What are the limitations of MongoDB?

The maximum BSON document size is 16 megabytes. The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth. To store documents larger than the maximum size, MongoDB provides the GridFS API.


1 Answers

You can use any (UTF8) character in the field name which aren't special (contains ".", or starts with "$").

https://jira.mongodb.org/browse/SERVER-3229

https://stackoverflow.com/a/7976235/311220

It's generally best to stick with lowercase alphanumeric with underscores though.

like image 52
Acorn Avatar answered Sep 23 '22 06:09

Acorn