[query] add fields list to query

This commit is contained in:
Maxime Alves LIRMM 2020-07-20 11:20:58 +02:00
parent ceb0b075de
commit 8930e065d2
3 changed files with 14 additions and 2 deletions

3
conf/env.mallirmm Normal file
View File

@ -0,0 +1,3 @@
DEV=1
DEBUG=1
DEBUG_ACL=public

View File

@ -70,7 +70,7 @@ def parse_query(q: str = ""):
split_ = lambda x : x.split(':') split_ = lambda x : x.split(':')
params = dict(map(split_, q.split('|'))) params = dict(map(split_, q.split('|')))
def select(obj): def select(obj, fields = []):
if 'limit' in params and int(params['limit']) > 0: if 'limit' in params and int(params['limit']) > 0:
obj.limit(int(params['limit'])) obj.limit(int(params['limit']))
@ -78,6 +78,6 @@ def parse_query(q: str = ""):
if 'offset' in params and int(params['offset']) > 0: if 'offset' in params and int(params['offset']) > 0:
obj.offset(int(params['offset'])) obj.offset(int(params['offset']))
return [elt for elt in obj.select()] return [elt for elt in obj.select(*fields)]
return select return select

9
scripts/get_token.py Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/python3
import requests
import json
r = requests.post('http://127.0.0.1:3000/auth',
data={'email':'dhenaut', 'password':'a'})
r_obj = json.loads(r.text)
token = r_obj['token']
print(token)