pymongo mongodb查询两个值

发布于 2025-01-21 09:54:50 字数 446 浏览 2 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文