javascript - Node.js data validation with multiple processes -


i noticed in node.js not easy validate data in db. example have next snippet of code

return dbservice.checkpossibilityaddentitybysomedata(t, data)             .then(function(itpossibleadd) {                 if(!itpossibleadd) {                     throw new error();                 }                 return dbservice.add(t, entity);             }) 

i add new entity, if query returns true.
but faced situation multiple processes tried add same entity , when 1 process conducted validation still not add entity process add entity. , result wrong data in database.
how deal ?


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

Command prompt result in label. Python 2.7 -