I need to know how to get the last record stored in the mongo.
I'm doing a search, comparing two IDS, I need to return only the last record.
I have the following variables:
client.name
client.cpf
client.endereço
I'm doing the search as follows:
Client.findById({$and: [{_id: client.Client.id}, {_id: contact.id}]}, {sort: {cpf: -1 }}, function(err, clients) {
console.log("client.id: "+client.Client.id)
console.log("post"+post)
console.log("imprimir: "+contact.code)
console.log("nome"+client.cpf)
callback();
});
},
But it does not work.