私はmeteorとmongoで新しいです。私は別の配列の内容である配列内の1つのオブジェクトをプッシュしたいと思います。私はカンティエリにプジョーニを欲しいです。しかし、私は1つの特定のcantieriでプッシュgiorniしたいと思います。どうすれば作れますか?この私のスキーマのコレクション。オブジェクトを流星1.4で配列に入れますか?
`Clienti.Giorni = new SimpleSchema({
giorno: {
type: Date,
label: "giorno del lavoro"
},
oraPartenza: {
type: Date,
label: 'Giorno e ora partenza',
},
oraInizio: {
type: Date,
label: 'Giorno e ora inizio',
optional: true
},
oraFine: {
type: Date,
label: 'Giorno e ora fine',
optional: true
},
dipendenti: {
type: [Dipendenti]
}
});
Clienti.Cantieri = new SimpleSchema({
_id:{
type: String,
autoValue: function(){
var id = new Meteor.Collection.ObjectID();
return id._str
}
},
nome: {
type: String
},
luogo: {
type: String
},
inizio: {
type: Date
},
scadenza: {
type: Date
},
inCorso: {
type: Boolean,
defaultValue: false
},
createdAt: {
type: Date,
label: "Creato il",
autoValue: function() {
return new Date()
}
},
giorni: {
type: [Clienti.Giorni],
optional: true,
autoform: {
type: "hidden"
}
}
});
Clienti.ClienteSchema = new SimpleSchema({
nome: {
type: String,
label: "nome"
},
iva: {
type: String,
label: "Partita iva",
max: 16
},
referente: {
type: String,
label: "Nome persona di rifermento"
},
email: {
type: String,
label: "email"
},
indirizzo:{
type:String,
label: 'Indirizzo'
},
createdAt: {
type: Date,
label: "Creato il",
autoValue: function() {
return new Date()
},
autoform: {
type: "hidden"
}
},
cantieri: {
type: [Clienti.Cantieri],
optional: true,
autoform: {
type: "hidden"
}
}
});
Clienti.attachSchema(Clienti.ClienteSchema);`
[this](http://stackoverflow.com/questions/27874469/mongodb-push-in-nested-array)のような何か? – MasterAM
実際にはこのソリューションを試しています 'aggiungiGiorno:function(id、idC、doc){ \t \t Clienti.update({_id:id、" cantieri._id ":idC}、{$ push:{ \t \t \t "cantieri.giorni":doc} \t \t}); \t} コンソールログは何も返さず、更新されたドキュメントはありません!どのようにそれを修正するのか分からない? –
[forum meteor](https://forums.meteor.com/t/push-object-in-array-help-me-please/29493/3) –