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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -