blaze v0.1.1 Blaze.API View Source
A wrapper around GoogleApi.Firestore.V1.Api.Projects
with simpler function
names and automatic conversion between native Elixir types and Firestore
models.
Connections
All connections are required to be Tesla connections, because that's what the
official API library requires. However, you can create your own Tesla
connection if you wish; the first parameter of every API function is a conn
.
If you don't want to create your own Tesla connection you may also use
connection/1
, passing in a Goth
token, which will generate a valid Tesla
connection for you. For example:
token = Goth.Token.for_scope(scope)
conn = Blaze.API.connection(token.token)
This doesn't do much except wrap GoogleApi.Firestore.V1.Connection.new/1
,
but this way you can alias/import a single module (Blaze.API
) rather than
having to start including the official library modules. After all, this
wrapper aims to completely remove the need to directly interact with the messy
official API library.
Link to this section Summary
Functions
Create a new Firestore connection.
Creates a new document. This will encode a native Elixir map to a document request prior to creation, as well as decoding the returned document model into a native Elixir map in the case of a successful response.
Deletes a document at the given path. This is typically the fully-qualified
collection path plus the document id. E.g.
projects/project-id/databases/(default)/documents/some_collection/document_id
.
Returns a document at the given path. This is typically the fully-qualified
collection path plus the document id. E.g.
projects/project-id/databases/(default)/documents/some_collection/document_id
.
List all documents stored within a given collection. You may use :pageSize
and :pageToken
in the opts
list to control how many results are returned
per page as well as which page to start on.
Parse a document response tuple so that any returned documents are native Elixir maps rather than Document models.
Runs a structured query against the database. It is recommended to use
Blaze.Query
to build the structured query model to pass to this function.
Updates a document at the given path. This is typically the fully-qualified
collection path plus the document id. E.g.
projects/project-id/databases/(default)/documents/some_collection/document_id
.
Link to this section Functions
Create a new Firestore connection.
Creates a new document. This will encode a native Elixir map to a document request prior to creation, as well as decoding the returned document model into a native Elixir map in the case of a successful response.
Deletes a document at the given path. This is typically the fully-qualified
collection path plus the document id. E.g.
projects/project-id/databases/(default)/documents/some_collection/document_id
.
If you do not have the unique identifier for a given document, you may query
for the document first by using list_documents/3
or run_query/3
.
Returns a document at the given path. This is typically the fully-qualified
collection path plus the document id. E.g.
projects/project-id/databases/(default)/documents/some_collection/document_id
.
If you do not have the unique identifier for a given document, you may query
for the document first by using list_documents/3
or run_query/3
.
List all documents stored within a given collection. You may use :pageSize
and :pageToken
in the opts
list to control how many results are returned
per page as well as which page to start on.
Parse a document response tuple so that any returned documents are native Elixir maps rather than Document models.
Runs a structured query against the database. It is recommended to use
Blaze.Query
to build the structured query model to pass to this function.
Updates a document at the given path. This is typically the fully-qualified
collection path plus the document id. E.g.
projects/project-id/databases/(default)/documents/some_collection/document_id
.
If a document does not exist at that path, a document is created.