1
I have the following question: I have a database in mongoDB, I search the data by Nodejs it returns everything right, but I would like to play this value of the search for a variable, to make a comparison. Type search the date in DB and I would like to compare this date with the current system date.
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 take the result of this search and play in a 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 : Data {date:'2016-12-04'}