Node.js MongoDB-NodeJs-超过最大调用堆栈大小
在MongoDB/NodeJs(使用Mongoose)中保存下面的模式时,我遇到了这个错误: 未捕获范围错误:超过最大调用堆栈大小。 当我在数组中的架构中添加详细信息时,会发生这种情况:Node.js MongoDB-NodeJs-超过最大调用堆栈大小,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,在MongoDB/NodeJs(使用Mongoose)中保存下面的模式时,我遇到了这个错误: 未捕获范围错误:超过最大调用堆栈大小。 当我在数组中的架构中添加详细信息时,会发生这种情况: var mongoose = require('mongoose'); const Attribute = new mongoose.Schema({ context: String, format: String, measurand: String, location: String,
var mongoose = require('mongoose');
const Attribute = new mongoose.Schema({
context: String,
format: String,
measurand: String,
location: String,
unit: String
});
const Value = new mongoose.Schema({
value: Number,
attributes: Attribute
});
module.exports = mongoose.model('MeterValue',{
chargeBoxID: {type: String, ref: 'ChargingStation'},
connectorId: Number,
transactionId: Number,
timestamp: Date,
values: [Value]
});
有什么想法吗
提前谢谢!
Serge.我认为您必须为数组中的模型定义一个额外的模式 比如:
const AddressSchema mongoose.Schema({
地址1:{type:String},
地址2:{type:String},
});
...
module.exports=mongoose.model('Person'{
_id:String,
名称:String,
地址:[AddressSchema],
});代码>非常感谢,但我也尝试过,但没有成功:(我更新了消息,以便您可以检查我的真实数据;-)我明白了。第一件事是你确定这是工作的{type:String,ref:'ChargingStation'}
我刚刚看到一个对象id引用。然后不清楚属性
是否仅表示一个属性
模式,或者它也是一个数组?是的,我将充电站的_id更改为字符串,因为它的名称是唯一的,因此更容易在其他模式中识别。这只是一个属性;我同意这和“属性”这个名字很混淆。