> when I save data to the collection which name is number start , the mongo
> prompt
> "Mon Jul 16 16:16:44 SyntaxError: missing ; before statement (shell):1 ",
> and my command is following:
> PRIMARY> use testwhb
> switched to db testwhb
> PRIMARY> db.a.save({"test":"1"})
> PRIMARY> db.1.save({"tet2":"1"})
> Mon Jul 16 16:16:44 SyntaxError: missing ; before statement (shell):1
> PRIMARY> show collections
> Does it mongo limit the collection name start with number??
Hi,
You can use a collection name starting with a number, but the mongo JS
shell recognizes that as a beginning a variable rather than a collection
name so you need to quote it:
> db["1"].save({"test2":1});
> db["1"].find();
{ "_id" : ObjectId("5003d9c1c27f710e17072683"), "test2" : 1 }
> db.getCollection("1").find()
{ "_id" : ObjectId("5003d9c1c27f710e17072683"), "test2" : 1 }
Cheers,
Stephen