-
Notifications
You must be signed in to change notification settings - Fork 369
Closed
Description
I defined a mysql model
{
id: {type: 'number'}
some_object: {type:'text'}
}, {
hooks: {
beforeSave: function (next){
this.some_object = JSON.stringify(this.some_object);
return next();
},
afterLoad: function (next){
this.some_object = JSON.parse(this.some_object);
return next();
}
}
}Every time I use it, it want the field is already a JSON obj and text in db
Seems that there is a caching mechanism:
- I get it by id immediately after I create one.
I found that theafterLoadwill not be called when I do some search thing - which causes the problem:
thebeforeSavehook is called at last, so the some_object in memory is text not obj
how about calling the afterLoad hook no matter it is in cache or not?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels