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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -