【问题标题】:using insertMany() in mogodb but I couldnt insert it eventhough the syntax is correct在 mongodb 中使用 insertMany() 但即使语法正确我也无法插入它
【发布时间】:2020-06-27 15:40:01
【问题描述】:

db.customers.insertMany( [

{

“姓名”:“客户1”,

“电子邮件”:“customer1@gmail.com”,

“电话”:64665656,

"hall_id":100

},

{

"name":"customer2",

“电子邮件”:“customer2@gmail.com”,

“电话”:6463155,

"hall_id":200

])

here is the screen shot of my code and the error

【问题讨论】:

  • 您遇到了什么问题?
  • 您遇到了什么错误。也在问题中更新。

标签: database mongodb mongodb-query


【解决方案1】:

您没有正确关闭第二个对象的花括号

试试这个,这会奏效:

db.customers.insertMany([
   {
      "name": "customer1",
      "email": "customer1@gmail.com",
      "phone": 64665656,
      "hall_id": 100
   },
   {
      "name": "customer2",
      "email": "customer2@gmail.com",
      "phone": 6463155,
      "hall_id": 200
   }
])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-03
    • 2021-06-22
    • 1970-01-01
    • 2020-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多