firebase.firestore package
A simple python wrapper for Google’s Firebase Cloud Firestore REST API
- class firebase.firestore.Collection(collection_path, api_key, credentials, project_id, requests)[source]
Bases:
object
A reference to a collection in a Firestore database.
- Parameters:
collection_path (list) – Collective form of strings to create a Collection.
api_key (str) –
apiKey
from Firebase configurationcredentials (
Credentials
) – Service Account Credentialsproject_id (str) –
projectId
from Firebase configurationrequests (
Session
) – Session to make HTTP requests
- add(data, token=None)[source]
Create a document in the Firestore database with the provided data using an auto generated ID for the document.
- end_at(document_fields)[source]
End query at a cursor with this collection as parent.
- Parameters:
document_fields (dict) – A dictionary of fields representing a query results cursor. A cursor is a collection of values that represent a position in a query result set.
- Returns:
A reference to the instance object.
- Return type:
- end_before(document_fields)[source]
End query before a cursor with this collection as parent.
- Parameters:
document_fields (dict) – A dictionary of fields representing a query results cursor. A cursor is a collection of values that represent a position in a query result set.
- Returns:
A reference to the instance object.
- Return type:
- get(token=None)[source]
Returns a list of dict’s containing document ID and the data stored within them.
- limit_to_first(count)[source]
Create a limited query with this collection as parent.
Note
limit_to_first and limit_to_last are mutually exclusive. Setting limit_to_first will drop previously set limit_to_last.
- Parameters:
count (int) – Maximum number of documents to return that match the query.
- Returns:
A reference to the instance object.
- Return type:
- limit_to_last(count)[source]
Create a limited to last query with this collection as parent.
Note
limit_to_first and limit_to_last are mutually exclusive. Setting limit_to_first will drop previously set limit_to_last.
- Parameters:
count (int) – Maximum number of documents to return that match the query.
- Returns:
A reference to the instance object.
- Return type:
- offset(num_to_skip)[source]
Skip to an offset in a query with this collection as parent.
- Parameters:
num_to_skip (int) – The number of results to skip at the beginning of query results. (Must be non-negative.)
- Returns:
A reference to the instance object.
- Return type:
- order_by(field_path, **kwargs)[source]
Create an “order by” query with this collection as parent.
- select(field_paths)[source]
Create a “select” query with this collection as parent.
- Parameters:
field_paths (list) – A list of field paths (
.
-delimited list of field names) to use as a projection of document fields in the query results.- Returns:
A reference to the instance object.
- Return type:
- start_after(document_fields)[source]
Start query after a cursor with this collection as parent.
- Parameters:
document_fields (dict) – A dictionary of fields representing a query results cursor. A cursor is a collection of values that represent a position in a query result set.
- Returns:
A reference to the instance object.
- Return type:
- start_at(document_fields)[source]
Start query at a cursor with this collection as parent.
- Parameters:
document_fields (dict) – A dictionary of fields representing a query results cursor. A cursor is a collection of values that represent a position in a query result set.
- Returns:
A reference to the instance object.
- Return type:
- where(field_path, op_string, value)[source]
Create a “where” query with this collection as parent.
- Parameters:
field_path (str) – A field path (
.
-delimited list of field names) for the field to filter on.op_string (str) – A comparison operation in the form of a string. Acceptable values are
<
,<=
,==
,!=
,>=
,>
,in
,not-in
,array_contains
andarray_contains_any
.value (Any) – The value to compare the field against in the filter. If
value
isNone
or a NaN, then==
is the only allowed operation. Ifop_string
isin
,value
must be a sequence of values.
- Returns:
A reference to the instance object.
- Return type:
- class firebase.firestore.Document(document_path, api_key, credentials, project_id, requests)[source]
Bases:
object
A reference to a document in a Firestore database.
- Parameters:
document_path (list) – Collective form of strings to create a Document.
api_key (str) –
apiKey
from Firebase configurationcredentials (
Credentials
) – Service Account Credentialsproject_id (str) –
projectId
from Firebase configurationrequests (
Session
) – Session to make HTTP requests
- collection(collection_id)[source]
A reference to a collection in a Firestore database.
- Parameters:
collection_id (str) – An ID of collection in firestore.
- Returns:
Reference to a collection.
- Return type:
- get(field_paths=None, token=None)[source]
Read data from a document in firestore.
- Parameters:
- Returns:
The whole data stored in the document unless filtered to retrieve specific fields.
- Return type:
- class firebase.firestore.Firestore(api_key, credentials, project_id, requests)[source]
Bases:
object
Firebase Firestore Service
- Parameters:
api_key (str) –
apiKey
from Firebase configurationcredentials (
Credentials
) – Service Account Credentialsproject_id (str) –
projectId
from Firebase configurationrequests (
Session
) – Session to make HTTP requests