You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.
Hi everyone!
Few days ago, I created a script for consult an information. But when i try excecute the script, this is blocked. It´s my code:
// The connection to database is Sync methodconstmassiveInstance=require('./app/models/connection'),moment=require('moment'),database=massiveInstance(),_=require('underscore')constscanDocuments=()=>{moment().format()lettoday=moment().format('YYYY-MM-DD')newPromise((resolve,reject)=>{database.getall_vehicle_person((err,result)=>{if(err){console.error(err)}else{// This methods are not important, only validate infoletperson_vehicle=format_object(result),notifications=validate_documents_vehicle(today,person_vehicle),licenses=validate_license_person(today,person_vehicle),final_notifications=_.union(licenses,notifications)}})resolve(final_notifications,today)}).then((final_notifications,today)=>{_.each(final_notifications,(value,key)=>{letnotify=database.notification.findOneSync({id : value.id})if(_.isEmpty(notify)){database.notification.insertSync(value)}else{if(notify.signal==='warning'&&value.signal==='danger'){database.notification.updateSync(value)}}})process.exit(0)})}
Note: The process.exit(0) is for kill the process, because when i not put this code, my script never stop. Please explain me this.
Which is the problem?
Because, when i use querys async the process is killed whitout consult the database.
Thanks for read! ☺️ 🙏
The text was updated successfully, but these errors were encountered:
Because, I have several modules in my app and i need to save the database instance in a variable. Now, How could i do? Should i insert the code in the callback ?
massive.connect({connString : connString},(err,db)=>{// My Code...})
vardatabase;massive.connect({connectionString: "connString"},function(err,db){database=db;// Your code....});Takealookkatthetestsandthereadmeforsomemoreusageexamples.
Hi everyone!
Few days ago, I created a script for consult an information. But when i try excecute the script, this is blocked. It´s my code:
Which is the problem?
Because, when i use querys async the process is killed whitout consult the database.
Thanks for read!☺️ 🙏
The text was updated successfully, but these errors were encountered: