Ich bin neu in Meteor und Mongo Ich möchte ein Objekt in einem Array, das Inhalt in dem anderen Array ist, schieben. Ich möchte Push giorni zu Cantieri. Aber ich möchte Push Giorni in einer bestimmten Cantieri. Wie kann ich es schaffen? Dies sind die Sammlungen meines Schemas.Objekt in Array mit Meteor 1.4 schieben?
`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);`
Etwas wie [dies] (http://stackoverflow.com/questions/27874469/mongodb-push-in-nested-array)? – MasterAM
ja in der Tat, ich versuche diese Lösung 'aggiungiGiorno: Funktion (ID, IDC, doc,) { \t \t Clienti.update ({_id: id," Cantieri._id ": IDC}, {$ push: { \t \t \t "cantieri.giorni": doc} \t \t}); \t} ' aber das Konsolenprotokoll gibt nichts zurück und das Dokument wird nicht aktualisiert! Ich weiß nicht, wie repariere ich das? –
[Forum Meteor] (https://forums.meteor.com/t/push-object-in-array-help-me-please/29493/3) –