D
D
Dream2021-08-03 21:06:39
Python
Dream, 2021-08-03 21:06:39

How to find users with a certain value and check them?

MongoDB has a structure:

'_id': member.id,
'premium': {
    'status': 0,
    'trial': 0,
    'class': None,
    'date': None
},


I use tasks.loop in discord.py and MongoDB . How can I make tasks.loop check only those users who have status: 1 , and then check the following chain by their class (Trial, 1 Week, 1 Month): if the user has Trial, then the subscription will be removed in a day, if 1 Week - then in a week, if 1 Month - then in a month. Well, date is checked against timedelta .

I just don't know how to find exactly all users with status: 1 and find their: class and date .

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rag'n' Code Man, 2021-08-04
@dreameddd

Pseudo-Mongodb code If you need more filtering by class, then
db.collection.find({"premium.status": 1})

db.collection.find({"premium.status": 1, "premium.class": {$in: ["class1", "class2"]}})

Well, the same with the date.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question