2017-04-06 16 views
0

以下のスキーマをMongoDB/NodeJs(Mongoose)に保存するとこのエラーが発生します。 未知のRangeError:最大呼び出しスタックサイズを超えました。MongoDB - NodeJs - 最大呼び出しスタックサイズを超えました

私は配列で私のスキーマに詳細を追加したときにこれが発生します。

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。

答えて

0

私は、配列のモデルに追加のスキーマを定義する必要があると思います。

ような何か:

const AddressSchema mongoose.Schema({ 
 
    address1: { type: String }, 
 
    address2: { type: String }, 
 
}); 
 

 
... 
 

 
module.exports = mongoose.model('Person',{ 
 
    _id: String, 
 
    name: String, 
 
    address: [ AddressSchema ], 
 
});

+0

どうもありがとうしかし、あなたは私の実際のデータを確認することができますので、私はまた、私はメッセージを更新成功:( – LucasBrazi06

+0

せずにこれを試していた;-) – LucasBrazi06

+0

私は見る。まず、これが動作していることを確かめてください。 '{type:String、ref: 'ChargingStation'}'私はオブジェクトID参照でそれを見ました。それで、 'attributes'がただ一つの' Attribute'スキーマを意味するのか、それとも配列ですか? –

関連する問題