【问题标题】:is there ways to enter special characters in mongodb in a collection有没有办法在集合中的mongodb中输入特殊字符
【发布时间】:2023-01-26 08:03:38
【问题描述】:

我要在字段中添加特殊字符 db.student.insert({"姓名":"abc","f/姓名":"abc"}) 注意:这里 mongodb 显示错误 f/name is not adding 那么我该如何添加呢?

以更多方式回答,

【问题讨论】:

标签: database mongodb terminal special-characters new-operator


【解决方案1】:

虽然不推荐使用 insert(应该使用 insertOne()),但它似乎仍然可以正常工作......

Enterprise replSet [primary] barrydb> db.student.insert({"name":"abc","f/name":"abc"}) 
DeprecationWarning: Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite.
{
  acknowledged: true,
  insertedIds: { '0': ObjectId("63d1c044eb9ba7eec74dda8b") }
}

Enterprise replSet [primary] barrydb> db.student.find()
[
  {
    _id: ObjectId("63d1c044eb9ba7eec74dda8b"),
    name: 'abc',
    'f/name': 'abc'
  }
]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-06
    • 2015-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-22
    相关资源
    最近更新 更多