I have the following question: I have a database in mongoDB, I do the search of the data by NodeJS it returns me all right, however I would like to play this search value for a variable, to make a comparison. Type I search the date in DB and would like to compare that date with the current date of the system.
const CRUD = {
retrieve:function(query,mod){
//console.log("Query",query);
Model.findOne(query,mod, function(err,data){
if(err) return console.log('ERRO: ',err);
return console.log('Dado',data);
});
};
Then I call this CRUD in another file. Is there a way to get the result of this search and play on one variable to compare with another? type like this:
var query3 = {data:'2016-12-04'};
var fields = {data:1,_id:0};
CRUD.retrieve(query3,fields);
The result of CRUD is this: Given {date: '2016-12-04'}