Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from fireo.fields import NestedModel
from fireo.queries import query_wrapper
from fireo.queries.base_query import BaseQuery
from fireo.utils import utils
class CreateQuery(BaseQuery):
"""Insert model into firestore
Methods
------
_doc_ref():
create document ref from firestore
_parse_field():
Get and return `db_value` from model `_meta`
_raw_exec():
save model into firestore and return the document
exec():
return modified or new instance of model
"""
from fireo.queries import query_wrapper
from fireo.queries.base_query import BaseQuery
from fireo.utils import utils
class GetQuery(BaseQuery):
"""Get model from firestore
Get model from firestore using Managers
Examples
--------
.. code-block:: python
class User(Mode):
name = TextField()
age = NumberField()
u = User(name="Azeem", age=26)
u.save()
# Getting model
user = User.collection.get(u.key)
from fireo.queries.base_query import BaseQuery
from fireo.utils import utils
from fireo.database import db
class DeleteQuery(BaseQuery):
"""Delete Document from firestore
Example
------
.. code-block:: python
class User(Mode):
name = TextField()
age = NumberField()
u = User(name="Azeem", age=26)
u.save()
# Deleting model
id = User.collection.delete(u.id)
print(id)
from fireo.fields import DateTime, NestedModel
from fireo.queries import query_wrapper
from fireo.queries.base_query import BaseQuery
from fireo.utils import utils
class UpdateQuery(BaseQuery):
"""Update document in firestore
Methods
------
_doc_ref():
create document ref from firestore
_parse_field():
Get and return `db_value` from model `_meta`
_raw_exec(transaction_or_batch):
Update document in firestore and return the document
exec(transaction_or_batch):
return modified instance of model
"""
from fireo.database import db
from fireo.fields.errors import FieldNotFound
from fireo.queries import query_wrapper
from fireo.queries.base_query import BaseQuery
from fireo.queries.delete_query import DeleteQuery
from fireo.queries.query_iterator import QueryIterator
from fireo.utils import utils
from google.cloud import firestore
class FilterQuery(BaseQuery):
"""Filter documents on the bases of where clauses
Filter document by filed name, You can also sort and limit the documents.
Attributes
----------
model: Model
Model instance
select_query: list
Where filter
n_limit: int
Number of documents
oderer_by: list
import inspect
from fireo.queries import query_wrapper
from fireo.queries.base_query import BaseQuery
class CreateQuery(BaseQuery):
"""Insert model into firestore
Methods
------
_doc_ref():
create document ref from firestore
_parse_field():
Get and return `db_value` from model `_meta`
_raw_exec():
save model into firestore and return the document
exec():
return modified or new instance of model
"""