MongoDB collection hyphenated name

前端 未结 2 1229
时光取名叫无心
时光取名叫无心 2021-02-01 12:46

I\'m using Node.js program to insert data into a MongoDB database. I have inserted data into a collection named \"repl-failOver\".

var mongoClient = require(\"mo         


        
2条回答
  •  春和景丽
    2021-02-01 13:09

    You are getting this error from accessing collections with specific characters (-, _, ). I explained the workaround here, but basically all you need is to do

    db.getCollection("repl-failOver").insert(...)

提交回复
热议问题