You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Alex,
Thanks for this simple yet very useful plugin!
I have a question, though: why don't you allow your virtual setter to receive the very same object that you can pass to -.all setter?
It would be very convenient to be able to pass back the same structure of document that is retrieved (without patching internationalized fields to add the .all prefix).
Here is what I would suggest for the virtual setter:
schema.virtual(path).get(function(param){// embedded and sub-documents will use language methods from the top level documentvarowner=this.ownerDocument ? this.ownerDocument() : thisreturnparam&¶m[owner.getLanguage()]}).set(function(value){// embedded and sub-documents will use language methods from the top level documentvarowner=this.ownerDocument ? this.ownerDocument() : thisif(typeof(value)==='string'){// if the value is a string, we assume this is the value for default languagethis.set(path+'.'+owner.getLanguage(),value)}else{// if the value is not a string, it may be an object containing all languages variations. Let's pass it to the .all setterthis.set(path+'.all',value)}})
What do you think about that?
The text was updated successfully, but these errors were encountered:
Hi Alex,
Thanks for this simple yet very useful plugin!
I have a question, though: why don't you allow your virtual setter to receive the very same object that you can pass to -.all setter?
It would be very convenient to be able to pass back the same structure of document that is retrieved (without patching internationalized fields to add the .all prefix).
Here is what I would suggest for the virtual setter:
What do you think about that?
The text was updated successfully, but these errors were encountered: