在db.create模型中使用Mongoose.Schema.Types.Decimal时发生ValidationError

版本:
mongoose@4.11.5 mongodb服务器版本:3.4.7

模型:

var mongoose = require('mongoose'), Schema = mongoose.Schema; var CheckSchema = new Schema({ providerName: String, number: String, date: { type: Date }, dateReceived: { type: Date }, amount: Schema.Types.Decimal, paymentType: String, comment: String, status: String, images: [Image], transactions: [Transaction], rejectedTransactions: [Transaction], payerName: String }); 

服务器代码:

 Check.create(newCheck, function (err, check) { if (err) { return _response.handleError(req, res, err, _logType); } return _response.handleSuccess(req, res, 200, _logType, check); }); 

返回这个错误:

 Check validation failed: amount: Cast to Decimal128 failed for value "123.98" at path "amount" ValidationError 

“金额”是作为一个数字来自客户。 当我把“金额”string成十二进制数据types时,它可以存储到数据库。

 newCheck.amount = newCheck.amount.toString(); 

每当我创build一个新的支票,我不想这样做。 我有一个很大的应用程序,我想要将乘法值更改为Decimal128。 在我的设置中是否有我缺less的东西?