minor improvements
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from beanie import PydanticObjectId
|
||||
from beanie.operators import And, Or, RegEx, Eq
|
||||
from beanie.operators import And, RegEx, Eq
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi_paginate import Page, Params, add_pagination
|
||||
@@ -18,6 +18,10 @@ def parse_sort(sort_by):
|
||||
return fields
|
||||
|
||||
|
||||
def Or(filters):
|
||||
return {'$or': filters}
|
||||
|
||||
|
||||
def parse_query(query: str, model):
|
||||
if query is None:
|
||||
return {}
|
||||
@@ -40,7 +44,10 @@ def parse_query(query: str, model):
|
||||
|
||||
and_array.append(operand)
|
||||
|
||||
return And(and_array) if len(and_array) > 1 else and_array[0]
|
||||
if and_array:
|
||||
return And(and_array) if len(and_array) > 1 else and_array[0]
|
||||
else:
|
||||
return {}
|
||||
|
||||
|
||||
def get_crud_router(model, model_create, model_read, model_update):
|
||||
|
||||
Reference in New Issue
Block a user