Closed pkpowell closed 3 years ago
As far as a can see in the docs your schema should be:
const prefs = new simplschema({
companyPrefs: Object,
"companyPrefs.companyName": String,
"companyPrefs.emailBaseFQDN": Array,
"companyPrefs.emailBaseFQDN.$": String,
})
Thanks, that helps!
Now I'm getting Match error: Unknown key in field $set
Previously the autoform-method returned an object (that passed check()
and clean()
) like this:
{ '$set':
{
'companyPrefs.companyName': 'abc',
'companyPrefs.emailBaseFQDN': [ 'xyz.com' ],
'apiKeys.googleMapsAPI': '123456',
}
}
With autoform v.6 and the new node simpl-schema it it comes with extra _id and 'modifier' keys
{ _id: '3SRKjSxmnnkJ6wMsp',
modifier:
{ '$set':
{ 'companyPrefs.companyName': 'abc',
'companyPrefs.emailBaseFQDN': [ 'xyz.com' ],
'apiKeys.googleMapsAPI': '123456',
}
} }
So in my method I've tried running check
and clean
on doc.modifier
:
let mod = doc.modifier
check(mod, schemas.prefs)
schemas.prefs.clean(mod, {
extendAutoValueContext: {
isInsert: false,
isUpdate: true,
isUpsert: false,
isFromTrustedCode: false
}
})
but it baulks at Unknown key in field $set
Yeah, I think I changed it to pass as a single object by default in order to work with mdg:validated-method. The default used to be two separate args. But you should only have to use doc.modifier
It would be nice to have in the Note about version 6 that the parameter of the method have change.
before it was methodName: function (modifier, _id) {}
now it's a single object methodName: function ({ modifier: _id }){}
.
for the error, I'm not sure but I think that node-simple-schema is didn't work with check
function like before :/
I've been experimenting with simpl-schema + autoform v.6 and a form with
method-update
will return keys with the question mark formatting from the schema in place. This didn't use to be the case. Is this a bug or do I need to change something in my code?Here's the corresponding schema