I want to know why using Bookshelf.js leaves Promises resolved, but actually does not save anything on a PostgreSQL database
The code was successfully working, but suddenly It stopped working, I'm using an AWS server with a Windows instance, and one thing I tried is to restart the server.
The first thing noticed, is that after the reboot, some Windows environment variables dissapeared, I added the Node.js, NPM, and PostgreSQL commands, but the code keeps on resolving without inserting.
In the code example below I added functions with the same pattern... create an instance of a Bookshelf model and save it.
new Invoice(Info).save().then(model => {
console.log('Saved Invoice');
SaveAddOn(model.id, AddOnData);
console.log('Line 546', model.id)
SaveReceiver(model.id, ReceiverData);
console.log('Line 548', model.id)
SaveIssuer(model.id, IssuerData);
console.log('Line 550', model.id)
SaveConcepts(model.id, ConceptsData);
console.log('Line 552', model.id)
if(TaxesData!=null) {
SaveTaxes(model.id, TaxesData, true);
console.log('Line 555', model.id)
}
SaveRelatedInvoices(model.id, RelatedInvoicesData);
console.log('Line 558', model.id)
CheckStatus(model.id,re, rr, tt, id);
console.log('Line 560', model.id)
resolve(model.id);
})
One other thing is that the console.log()
functions inside the then()
method are not working, but every console.log()
outside, they do...
I believe this is a common issue with Bookshelf, but I hope somebody can help me on how to approach this problem.
All this happened because some dependencies inside node_modules were broken after installing another package.
After being overwhelmed and frustrated on how to resolve the problem I merged a local node_modules backup and the code started to work again.