Update: User.ad add Dates in views when getting ads
This commit is contained in:
parent
e6c28fb41f
commit
b5bb8e7cc4
1 changed files with 2 additions and 2 deletions
|
|
@ -429,7 +429,7 @@ exports.ad = (req, res) => {
|
||||||
for(const i in data){ids.push(data[i]._id);}
|
for(const i in data){ids.push(data[i]._id);}
|
||||||
Ad.updateMany({_id: {$in: ids}}, {$push: {views: [new Date()]}})
|
Ad.updateMany({_id: {$in: ids}}, {$push: {views: [new Date()]}})
|
||||||
.then(dataUpdate => {
|
.then(dataUpdate => {
|
||||||
if(dataUpdate && dataUpdate.modifiedCount === parseInt(quantity, 10)){
|
if(dataUpdate && dataUpdate.modifiedCount > 0){
|
||||||
return sendMessage(res, 11, data, token);
|
return sendMessage(res, 11, data, token);
|
||||||
} else {
|
} else {
|
||||||
return sendError(res,500,101,`Some error occurred while updating ${quantity} ad(s) for the User.`, token);
|
return sendError(res,500,101,`Some error occurred while updating ${quantity} ad(s) for the User.`, token);
|
||||||
|
|
@ -445,7 +445,7 @@ exports.ad = (req, res) => {
|
||||||
for(const i in data){ids.push(data[i]._id);}
|
for(const i in data){ids.push(data[i]._id);}
|
||||||
Ad.updateMany({_id: {$in: ids}}, {$push: {views: [new Date()]}})
|
Ad.updateMany({_id: {$in: ids}}, {$push: {views: [new Date()]}})
|
||||||
.then(dataUpdate => {
|
.then(dataUpdate => {
|
||||||
if(dataUpdate && dataUpdate.modifiedCount === parseInt(quantity, 10)){
|
if(dataUpdate && dataUpdate.modifiedCount > 0){
|
||||||
return sendMessage(res, 11, data, token);
|
return sendMessage(res, 11, data, token);
|
||||||
} else {
|
} else {
|
||||||
return sendError(res,500,101,`Some error occurred while updating ${quantity} ad(s) for the User.`, token);
|
return sendError(res,500,101,`Some error occurred while updating ${quantity} ad(s) for the User.`, token);
|
||||||
|
|
|
||||||
Reference in a new issue