Closed ckpiggy closed 7 years ago
Show me your route declaration please with this schema.
controllers/user.js
exports.install = function () {
F.route('/api/user', save, ['post', 'json', '*User#C'])
F.route('/api/user', save, ['put', 'json', '*User#U'])
}
function save(){
this.$save()
}
models/user.js
NEWSCHEMA('User').make(function(schema) {
schema.define('id', Number, true, 'U')
schema.define('name', String, true, 'C')
schema.define('email', String, true, 'C')
schema.define('name, String, false, 'U')
schema.define('email', String, false, 'U')
schema.setSave(function ($){
/*...some code...*/
})
})
I know so... You can't declare two same fields with different filter. This is not possbible. I recommend to set schema.setValidate()
for create
or create two schemas create
and update
. I recommend to create two schemas.
Thanks !!
For example: A user schema got 3 properties :
id
,name
,email
, and the 3 properties are all required only when creating. I want to allow user only change email or name.these code wont work when I trying to update name with put body
{id: 'myId', name: 'new name'}
, framework send errors to me.Is there any option to setup these properties? Or I should just simply create another schema for update operation?