我有一个 MongoDB 集合,名为:ec2_list-07-26-2020
如果我尝试对其进行典型操作,find()或者validate()出现此错误:
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
Run Code Online (Sandbox Code Playgroud)
所以我创建了一个名为:的测试集合audit00。当我对该集合执行相同操作时,效果很好:
db.audit00.find()
{ "_id" : ObjectId("5f1e1e02807681425a06fa07"), "writeConcern" : "yes", "ordered" : "True" }
Run Code Online (Sandbox Code Playgroud)
和:
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
}
Run Code Online (Sandbox Code Playgroud)
我为集合命名的方式是否有问题需要更改?
我不认为你的收藏名称有什么问题。它不违反任何MongoDB 命名限制。
以下命令应该在 mongo 中工作shell:
const col = db.getCollection("ec2_list-07-26-2020")
col.find()
Run Code Online (Sandbox Code Playgroud)
或者
db["ec2_list-07-26-2020"].find()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1815 次 |
| 最近记录: |