【问题标题】:Mongodb [js] uncaught exception: SyntaxError: identifier starts immediately after numeric literalMongodb [js] 未捕获的异常:SyntaxError:标识符在数字文字之后立即开始
【发布时间】:2020-11-16 07:18:02
【问题描述】:

我有一个 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

所以我创建了一个名为:audit00 的测试集合。当我对该集合执行相同操作时,它可以正常工作:

 db.audit00.find()
{ "_id" : ObjectId("5f1e1e02807681425a06fa07"), "writeConcern" : "yes", "ordered" : "True" }

还有:

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
}

我命名收藏的方式是否有问题需要更改?

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    我认为您的收藏名称没有任何问题。它不违反任何MongoDB naming restriction

    以下命令应该在 mongo shell 中工作:

    const col = db.getCollection("ec2_list-07-26-2020")
    col.find()
    

    db["ec2_list-07-26-2020"].find()
    

    【讨论】:

      猜你喜欢
      • 2021-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多