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
This should be reasonably simple to implement, I'm just pitching the idea.
Let's say I wanted to define a plugin that would serialize an instance to JSON/Javascript with a whitelist or a blacklist. As of right now that is not possible, plus there are currently no model specific settings. Say I defined a plugin with the code below with a beforeDefine hook.
functionPlugin(db){return{// This uses the properties and opts passed into the Model constructor.beforeDefine: function(name,properties,opts){// Now we can intercept and add the methods we want.if(!Array.isArray(opts.visible)){return;}opts.methods=opts.methods||{};opts.methods.toJs=function(){// Code to filter model instance fields based on the fields provided in the opts.visible Array};opts.methods.toJson=function(){returnJSON.serialize(opts.methods.toJs());};}};}
Now that is all possible. Does this seem like a reasonable idea to you guys?
The text was updated successfully, but these errors were encountered:
This should be reasonably simple to implement, I'm just pitching the idea.
Let's say I wanted to define a plugin that would serialize an instance to JSON/Javascript with a whitelist or a blacklist. As of right now that is not possible, plus there are currently no model specific settings. Say I defined a plugin with the code below with a
beforeDefine
hook.Now that is all possible. Does this seem like a reasonable idea to you guys?
The text was updated successfully, but these errors were encountered: