5.0.5 • Published 1 year ago

@proteansoftware/capacitor-firestore v5.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@proteansoftware/capacitor-firestore

Capacitor Plugin for Native Firestore

Install

npm install @proteansoftware/capacitor-firestore
npx cap sync

API

getPendingActions()

getPendingActions() => Promise<PendingActions>

Gets the number of pending write actions (i.e. setDocument, addDocument, updateDocument, deleteDocument)

Returns: Promise<PendingActions>


initializeFirestore(...)

initializeFirestore(options: FirestoreConfig) => Promise<void>

Configure the firestore instance with new configuration options.

ParamType
optionsFirestoreConfig

signInWithCustomToken(...)

signInWithCustomToken(options: CustomToken) => Promise<void>

Login to firestore using a customer JWT token.

ParamType
optionsCustomToken

signOut()

signOut() => Promise<void>

Sign out of firestore.


getDocument(...)

getDocument<T>(options: DocumnentQuery) => Promise<DocumentSnapshot<T>>

Reads the document referred to by this DocumnentQuery

ParamType
optionsDocumnentQuery

Returns: Promise<DocumentSnapshot<T>>


updateDocument(...)

updateDocument<T>(options: UpdateDocument<T>) => Promise<void>

Updates fields in the document referred to by the specified DocumnentQuery. The update will fail if applied to a document that does not exist.

ParamType
optionsUpdateDocument<T>

setDocument(...)

setDocument<T>(options: SetDocument<T>) => Promise<void>

Writes to the document referred to by the specified DocumnentQuery. If the document does not yet exist, it will be created. If you provide merge or mergeFields, the provided data can be merged into an existing document.

ParamType
optionsSetDocument<T>

deleteDocument(...)

deleteDocument(options: DocumnentQuery) => Promise<void>

Deletes the document referred to by the specified DocumnentQuery.

ParamType
optionsDocumnentQuery

addDocument(...)

addDocument<T>(options: AddDocument<T>) => Promise<DocumentReference>

Add a new document to specified CollectionQuery with the given data, assigning it a document ID automatically.

ParamType
optionsAddDocument<T>

Returns: Promise<DocumentReference>


addDocumentSnapshotListener(...)

addDocumentSnapshotListener<T>(options: DocumnentQuery, callback: DocumentSnapshotCallback<T>) => Promise<CallbackId>

Listen for snapshot changes on a document.

ParamType
optionsDocumnentQuery
callbackDocumentSnapshotCallback<T>

Returns: Promise<string>


getCollection(...)

getCollection<T>(options: CollectionQuery) => Promise<CollectionSnapshot<T>>

Executes the query and returns the results as a CollectionSnapshot

ParamType
optionsCollectionQuery

Returns: Promise<CollectionSnapshot<T>>


addCollectionSnapshotListener(...)

addCollectionSnapshotListener<T>(options: CollectionQuery, callback: CollectionSnapshotCallback<T>) => Promise<CallbackId>

Listen for snapshot changes on a collection.

ParamType
optionsCollectionQuery
callbackCollectionSnapshotCallback<T>

Returns: Promise<string>


removeSnapshotListener(...)

removeSnapshotListener(options: RemoveSnapshotListener) => Promise<void>

Stop listening for snapshot changes on a document or collection.

ParamType
optionsRemoveSnapshotListener

clearAllSnapshotListeners()

clearAllSnapshotListeners() => Promise<void>

Remove all active snapshot listners


enableNetwork()

enableNetwork() => Promise<void>

Re-enables use of the network for this Firestore instance after a prior call to {@link disableNetwork}.


disableNetwork()

disableNetwork() => Promise<void>

Disables network usage for this instance. It can be re-enabled via {@link enableNetwork}. While the network is disabled, any snapshot listeners, {@link getDocument} or {@link getCollection} calls will return results from cache, and any write operations will be queued until the network is restored.


Interfaces

PendingActions

PropType
countnumber

FirestoreConfig

PropTypeDescriptionSince
projectIdstringSet the GCP/Firebase project id1.0.0
applicationIdstringSet the Firebase application id1.0.0
apiKeystringSet the Firebase api key1.0.0

CustomToken

PropType
tokenstring

DocumentSnapshot

PropTypeDescriptionSince
dataT | nullThe fields of the document or null if the document doesn't exist.1.0.0

DocumnentQuery

PropTypeDescription
referencestringA reference to the document/collection

UpdateDocument

PropTypeDescription
dataPartial<T>An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document

SetDocument

PropTypeDescription
dataTA map of the fields and values for the document.
mergebooleanChanges the behavior of a setDocument() call to only replace the values specified in its data argument. Fields omitted from the setDocument() call remain untouched. If your input sets any field to an empty map, all nested fields are overwritten.

DocumentReference

PropTypeDescriptionSince
idstringThe id of the document.1.0.0
pathstringA string representing the path of the referenced document (relative to the root of the database).1.0.0

AddDocument

PropTypeDescription
dataTAn Object containing the data for the new document.

CollectionSnapshot

PropType
collectionDocumentSnapshot<T>[]

CollectionQuery

PropType
queryConstraintsQueryConstraint[]

QueryConstraint

A QueryConstraint is used to narrow the set of documents returned by a Firestore query.

PropTypeDescription
fieldPathstringThe path to compare
opStrQueryOperatorsThe operation string (e.g "<", "<=", "==", "<", "<=", "!=", "array-contains")
valueanyThe value for comparison

RemoveSnapshotListener

PropType
callbackIdCallbackId

Type Aliases

Partial

Make all properties in T optional

{ P in keyof T?: TP; }

DocumentSnapshotCallback

(data: DocumentSnapshot<T> | null, err?: any): void

CallbackId

string

QueryOperators

Filter conditions in a {@link QueryConstraint} clause are specified using the strings '<', '<=', '==', '>=', '>', 'array-contains'

"==" | ">=" | "<=" | "<" | ">" | "array-contains"

CollectionSnapshotCallback

(data: CollectionSnapshot<T> | null, err?: any): void

5.0.5

1 year ago

5.0.4

1 year ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

4.2.3

2 years ago

4.2.2

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

5.0.0

2 years ago

4.2.0-alpha2

2 years ago

4.2.0-alpha3

2 years ago

4.2.0-alpha

2 years ago

3.1.0

3 years ago

3.0.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.33

3 years ago

0.0.34

3 years ago

0.0.35

3 years ago

0.0.36

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.1.3

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago