pymongo mongodb查询两个值
我正在使用Pymongo 4.1.1,我试图一次用两件事进行排序。
答:用户单词计数
B:他们最后一次说一个字。
计划:我的计划是为最活跃的用户制作每周的服务器排行榜。
代码:
test=BADword.aggregate([
{"$match":{"guild":UWUserver}},
{"$sort":{"lastWORD":-1,"weeklyCount":-1}},
])
我正在存储最后一个单词,例如:1649964397333
。 我的想法是首先匹配公会,然后匹配最后一个单词的时间,然后检查是否在本周之内。但是我什至可以这样做吗?我找不到任何可以在$匹配中检查当前时间的检查,而只需要在本周内检查的人。 IE。 epochmilli,因为那是我存储最后一个单词的方式...
I am using pymongo 4.1.1 and i am trying to sort by two things at once.
A: The users word count
B: The last time they said an word.
Plan: My plan was to make an weekly server leaderboard for the most active user.
Code:
test=BADword.aggregate([
{"$match":{"guild":UWUserver}},
{"$sort":{"lastWORD":-1,"weeklyCount":-1}},
])
I am storing the last word like: 1649964397333
.
My idea was to first match the guild and then the lastWORD time and check if that is within this week. But can i even do that? I did not found anything how i could make a check in the $match where it checks for current period of time and only takes those who are within this week. ie. epochmilli since that is how i store the last word...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论