版本:
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
"量"来自客户端的数字。当我字符串化"金额"它以dbimal128类型成功地存储到数据库中。
newCheck.amount = newCheck.amount.toString();
每次创建新支票时,我都不想这样做。我有一个大型的应用程序,我想将乘法值更改为Decimal128。在我的设置中是否有我遗漏的东西?