I could not do this assignment, is something missing?
global.pedido = db.collection('configuracoes').findOne({ parametro: "pedido_num"})
I could not do this assignment, is something missing?
global.pedido = db.collection('configuracoes').findOne({ parametro: "pedido_num"})
You can try putting in a callback function to find an error, if it exists. For example:
try {
global.pedido = db.collection('configuracoes').findOne({ parametro: "pedido_num"});
} catch (error) {
console.log('>>>>>> Error: ', error);
}
findOne
returns a Promise , so the result is only ready when it is resolved. The result can be used as follows:
db.collection('configuracoes').findOne({ parametro: "pedido_num"}, function(err, document) {
if ( !err ) global.pedido = document;
});