问题描述
mongodb中有的特殊字符不能作为key,比如".",请问一下大家一共有多少种特殊字符不能作为key?
解决方案
请参考mongodb手册http://docs.mongodb.org/manual/reference/limits/#Restrictions%20on%20Field%20NamesNaming RestrictionsRestrictions on Database NamesThe dot (i.e. .) character is not permissible in database names.Database names are case sensitive even if the underlying file system is case insensitive.Changed in version 2.2: For MongoDB instances running on Windows.In 2.2 the following characters are not permissible in database names:/. "*<>:|?See Restrictions on Database Names for Windows for more information.Restriction on Collection NamesNew in version 2.2.Collection names should begin with an underscore or a letter character, and cannot:contain the $.be an empty string (e.g. "").contain the null character.begin with the system. prefix. (Reserved for internal use.)See Are there any restrictions on the names of Collections? and Restrictions on Collection Names for more information.Restrictions on Field NamesField names cannot contain dots (i.e. .), dollar signs (i.e. $), or null characters. See Dollar Sign Operator Escaping for an alternate approach.
解决方案二:
""空字符串、空格、$、/、、(空字符)