【发布时间】:2018-02-06 14:46:52
【问题描述】:
我尝试使用
db.orders.insert({"Price":NumberDecimal("12.34")})
它会抛出这个错误
"ReferenceError: NumberDecimal is not defined" 在 Node.js 中
但它在robo3T中运行良好
db.getCollection('orders').insert({"Price":NumberDecimal("12.34")})
MongoDB shell 版本:v3.4.7
MongoDB服务器版本:3.4.7
【问题讨论】:
-
您能否edit 向我们展示您使用代码的上下文?尝试在没有
NumberDecimal()包装器的情况下插入,即db.orders.insert({"Price": 12.34}, (err, result) => console.log(result)); -
请再次验证shell版本,这应该从shell版本3.4开始工作
-
这很好用 - db.orders.insert({"Price": 12.34}, (err, result) => console.log(result));
-
但我的问题是为什么 NumberDecimal() 会抛出错误
-
我仔细检查了 -MongoDB shell 版本:v3.4.7 MongoDB 服务器版本:3.4.7
标签: javascript node.js mongodb mean-stack