ko-bot on gh-pages
First commit Site updated: 2019-01-24 14:53:… (compare)
freenice12 on master
v8.14.1, v8.15.0 번역 (#798) * t… (compare)
ko-bot on gh-pages
First commit Site updated: 2019-01-24 09:09:… (compare)
ko-bot on gh-pages
First commit Site updated: 2019-01-24 09:09:… (compare)
yous on master
V11.7.0 (#797) * translate v11… (compare)
@HaroonGhawsi
Hi everyone, i am working on a voting app and using react redux with mongodb. In the backend I want the user should be allowed only three votes. I am saving user votes as an array in the document with time stamp and user id. How can I remove the first array element when user votes for the fourth time?
By the way the time stamp and user id is being saved in array as an object
so every element of array is an object and the length of array is the total votes for a particular document. @HaroonGhawsi
I want the last array element of the particular user should be deleted once the user votes for the fourth time
I have user mongodb update and aggregation but it is not giving me the result.
I sort the objects within the array by timestamp and remove the smallest timestamp var usrVote = aDatabase.collection('featureCollection').aggregate([
// {
// $match: { "feature_Votes.user_id": sessionModule.getDetails().dn}
// },
// {
// $sort: {"feature_Votes.TimeStamp": -1}
// },
// {
// $pull: {"feature_Votes": {$lt: }}
// }
{
$sort: {"feature_Votes.TimeStamp": -1}
},
{
$group:
{
_id: "$feature_Votes.user_id",
lastTimeStamp: {$last: "$feature_Votes.TimeStamp"}
}
}
], function(err, result){
if(err){
aReject(err);
console.log('User Vote Customization Failed');
return;
}
aResolve();
console.log('User Vote Customization Success');
console.log(result);
})
});