I am having two resources,
Users resource:
users = {
'schema': {
'username': {
'type': 'string',
'required': True
},
'interests': {
'type': 'list'
}
}
}
Example,
{"username": "Yogi", "interests":["Sports", "News"]}
Events resource:
events = {
'schema': {
'name': {
'type': 'string',
'required': True,
},
'categories': {
'type': 'list',
'required': True,
'minlength':1
}
}
}
Example,
{"name": "IPLT20", "categories": ["Sports"]}
Is there a way in Python Eve to query all events matching the interest of the user.
One way is to construct query like below,
/events?where={"$or":[{"categories":"Sports"},{"categories":"News"}]}
for this we'll have do a GET of user and using that information we'll have to construct the above query.
Is it possible in Python Eve to have a (one step) query something like,
/users/<userid>/events
or
/events?for=<userid>
events should be something like:
But this will make you work with events only through
users/<regex("[a-zA-Z0-9]{24}":user_id>/events
link. If you want to keep/events
endpoint as well use this approach