I'm using node.js, RailwayJS and JugglingDB.
I have a model:
Model.afterInitialize = function() {
var me = this;
Sequence.getSequence('forModel', function(sequence) {
me.serialId = sequence;
});
me.title = 'Hello';
}
Once it's all done only the attribute title
is set. This isn't surprising but I cannot get it to work. I tried using the async
module with no luck.
Model.afterInitialize
is part of an third-party API that I cannot change, so unfortunately there is no way to do this. I was hoping some sort of infinite loop checking for a flag would work but it doesn't and it would be a bodge even if it did work.
I ended up hooking into another method Model.beforeSave = function(callback) {};
, which requires a callback.
FYI I was using https://github.com/1602/jugglingdb