Reputation: 1325
I have a MongoDB collection called: ec2_list-07-26-2020
If I try to do typical operations on it like find()
or validate()
I get this error:
db.ec2_list-07-26-2020.find()
2020-07-26T20:17:16.845-0400 E QUERY [js] uncaught exception: SyntaxError: identifier starts immediately after numeric literal :
@(shell):1:18
So I created a test collection called: audit00
. When I do the same on that collection it works fine:
db.audit00.find()
{ "_id" : ObjectId("5f1e1e02807681425a06fa07"), "writeConcern" : "yes", "ordered" : "True" }
And:
db.audit00.validate()
{
"ns" : "aws_inventories.audit00",
"nInvalidDocuments" : NumberLong(0),
"nrecords" : 1,
"nIndexes" : 1,
"keysPerIndex" : {
"_id_" : 1
},
"valid" : true,
"warnings" : [
"Some checks omitted for speed. use {full:true} option to do more thorough scan."
],
"errors" : [ ],
"extraIndexEntries" : [ ],
"missingIndexEntries" : [ ],
"ok" : 1
}
Is there something wrong in the way that I'm naming my collections that needs to change?
Upvotes: 2
Views: 1937
Reputation: 2274
I don't think there is anything wrong with your collection name. It doesn't violate any MongoDB naming restriction.
Following command should work in mongo shell
:
const col = db.getCollection("ec2_list-07-26-2020")
col.find()
OR
db["ec2_list-07-26-2020"].find()
Upvotes: 5