asynchronous - findOrCreate creates duplicates -
asynchronous - findOrCreate creates duplicates -
i'm using oracle adapter, async.each , findorcreate transfer   info oracle postgres db:
//simplified version oracle.select(sql, [], function(err, results) {     async.each(results, function(add_me, async_cb){         model_to_add.findorcreate(             {not_id_field: add_me.value},             {required_fields: add_me.values}         ).exec(function add_me_cb(err, record){             if (record && !err){                 async_cb();             }         });     }); })    my sql query returns multiple, not unique values not_id_field. want unique in postgres db. thought finorcreate great thing use. somehow fails find record. 
was wrong? or maybe there's i'm missing? sails.js documentation isn't helpful : (
turns out problem me - didn't understand how async.each works , executed every item in array @ same time. switched async.eachseries , works fine.
 asynchronous each sails.js waterline sails-postgresql 
 
  
Comments
Post a Comment