mam schematu jak tak (puch wyciąć):SimpleSchema nieprawidłowe klucze z zagnieżdżonego autoValue
Schemas.people = new SimpleSchema({
note: {
type: [Schemas.notes],
optional: true,
defaultValue: []
},
updates: {
type: [Schemas.updates],
optional:true,
autoValue:function(){
if (this.isInsert) {
return [{
at: new Date,
user_id: this.userId
}];
}
return {
$push:{
at: new Date,
user_id: this.userId
}
}
}
}
});
a schemat notatki wygląda następująco:
Schemas.notes = new SimpleSchema({
note: {
type: String,
autoform: {
afFieldInput:{
type:"textarea"
}
},
optional: true
},
updates: {
type: [Schemas.updates],
optional:true,
autoform:{
omit:true
},
autoValue:function(){
if (this.isInsert) {
return [{
at: new Date,
user_id: this.userId
}];
}
return {
$push:{
at: new Date,
user_id: this.userId
}
}
}
}
});
a schemat aktualizacje jest bardzo prosta:
Schemas.updates = new SimpleSchema({
at: {
type: Date
},
user_id:{
type: Meteor.ObjectID
}
});
w „aktualizacje” pola na schemacie people
zapisuje identyfikator data/użytkownika zgodnie z oczekiwaniami, gdy się Data jest zrobiona. Jednak to nie na notes
schematu:
SimpleSchema invalid keys for "blablabla" context:
0: Object
name: "note.0.updates.0.at"
type: "keyNotInSchema"
value: Mon May 11 2015 11:57:58 GMT-0400 (Eastern Daylight Time)
1: Object
name: "note.0.updates.0.user_id"
type: "keyNotInSchema"
value: "abcd1234"
wierzę, że „nazwa” powinna wyglądać „people.note.0.updates.0.at”, ale jestem pewien, że to założenie jest poprawne i Nie jestem całkowicie pewien, jak to zrobić.
Aktualizacja:
kod używany do aktualizacji people
{{#autoForm collection="people" id=formId type="update" class="update" autocomplete="off" doc=getDocument autosave=true template="quickform"}}
{{> afQuickField name='note' template="quickform" }}
{{/autoForm}}
formId
zwraca randomish ciąg identyfikatora i getDocument
przechodzi prawidłowego odbioru.
Schemas.notes._schemaKeys
nie zawiera pól at
i user_id
... ale ma.
Ludzie schemat przedstawia: [. "Aktualizacje $ na" ... "aktualizacje $ user_id."., ...] Schemat
Uwagi pokazuje: [ "Uwaga", "aktualizacje" "updates. $"]
Jak dziwacznie.
Czy możesz podać kod, który aktualizuje dokument 'people'? –
@BrianShamblen Dodałem go, ale jest to dość prosty kod autoformułowy. –