aggreate data in mongodb


db.targetUsers.aggregate([
{
"$sort":{
"userId":1
}
},
{
"$group":{ "_id":"$mid",
"mid":{
"$first":"$mid"
},
"userId":{
"$first":"$userId"
},
"gender":{
"$first":"$gender"
},
"paidTime":{
"$first":"$paidTime"
},
"isFollowing":{
"$first":"$isFollowing"
},
"updatedAt":{
"$first":"$updatedAt"
}
}
},
{
"$match":{
"userId":{
"$gte":2098,
"$lte":2110
}
}
}
])

Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch