Я новичок в метеор и монго Я хотел бы нажать один объект в массиве, который является содержимым в другом массиве. Я хотел бы нажать giorni на 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);`
Что-то вроде [этого] (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) –