Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用模型中的Mongoose.Schema.Types.Decimal在db.create上运行时出现ValidationError_Node.js_Mongodb_Mongoose Schema - Fatal编程技术网

Node.js 使用模型中的Mongoose.Schema.Types.Decimal在db.create上运行时出现ValidationError

Node.js 使用模型中的Mongoose.Schema.Types.Decimal在db.create上运行时出现ValidationError,node.js,mongodb,mongoose-schema,Node.js,Mongodb,Mongoose Schema,版本: 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 }, am

版本:
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
“金额”以数字形式来自客户。当我将“amount”字符串化时,它成功地将其存储为十进制128类型

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

我不想每次创建新支票时都这样做。我有一个大型应用程序,我想把乘法值改为小数128。我的设置中是否缺少某些内容

您可以考虑使用
{type:Number}
表示金额