3
I have a schema
date, status and code:
var entregaSchema = mongoose.Schema({
codEntrega: String,
placaPipa: String,
codRota: String,
codMA: String,
dataMA: Date,
localMA: String,
codPA: String,
dataPA: Date,
localPA: String,
statusEntrega: String,
cadEntrega: Date
});
I’d like to sweep this scam and bring the biggest date to the codPA
past and with status to 3 which would be finalised.
Type: for the codPA = 34
, where there is a longer date and status = 3, this will be executed in a for
for each PA
, 1,2.. 34 and to find will perform another function of inserting a new delivery for this PA
if a time calculation is made in relation to the last date brought with a past time. Type, if dataPA >= 7
Insert delivery to this codPA
.