Open ArkeologeN opened 9 years ago
I'm agree with you, objects should serialize only their own parameters for storage.2 ways to do that :
1 - as Javascript is permissive you could construct or assign to an object a property that should not be stored in couchbase.
2 - from construct or when an undefinded property is set it should trigger an error
You see other ways to do this ?
I think going with 1st solution is fine. However, we could interpolate properties from schema when firing a save
event or action. Initially:
setter
to define a property, we could either ignore it for a while or bind a event emitter to raise error immediately. If we ignore it for a while, we can validate the entire object with schema onSave
.What do you think?
If we go with the first solution, I could be permissive on construct & setters, and at onSave pass to couchbase an new intermediate POJO mapped with only defined properties.
Currently, if you pass any field that is not part of your
declare
ormodel
, it would still allow you to set one. e.g:When you directly refer any object (in my case
req.body
), it will set those fields over object and it looks like this:It was reproduced using this:
Thanks!