0
内のオブジェクトの配列にデフォルト値を設定する
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var patientSchema = new Schema({
resourceType : {type :String, default : 'Patient' },
id : {type : String, default : 'example'},
text : [{
status : {type : String, default : 'generated'},
div :{type : String, default :'<div> Something </div>'}
}],
active : {type : String, default : 'true'},
identifier : [{
use : {type : String, default : 'official'},
system : {type : String, default : 'urn:oid:1.2.36.146.595.217.0.1'},
assinger :[{
display : {type : String, default : 'Acme Healthcare'},
}]
}],
name: [{
use : {type : String, default : 'official'},
first_name : {type : String, default : ''},
second_name : {type : String, default : ''}
}],
gender :{type : String, default : ''},
birthDate :{type : String, default : ''},
telecom : [{
system : {type : String, default : ''},
value : {type : String, default : ''}
}],
address : [{
use : {type : String, default : 'official'},
text : {type : String, default : ''},
city : {type : String, default : ''},
district : {type : String, default : ''},
state : {type : String, default : ''},
postalcode :{type : String, default : ''}
}]
});
var patients = mongoose.model('Patients',patientSchema);
module.exports = patients;
これは私が、ポストマンツールからフィールドなどの配列内部 デフォルト値を値を送信しています、私のモデルクラスです。 マングース
text : [{
status : {type : String, default : 'generated'},
div :{type : String, default :'<div> Something </div>'}
}],
状態とdivの
は、デフォルト値 私はデフォルトとして地位とDIVの値を格納する必要がを格納していません!
だからあなたは(私は答えを理解していることを確認するために頼む)私は、スキーマとしてテキストフィールドを持っているし、テキストフィールド内にそれをプッシュします。 – Grijan
はい、あなたは正しく理解しました。それはもっと多くの作業のように見えますが、再利用できるので、テキストフィールドを別の場所に置いておきたいときにも時間を節約できます! –