Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Transaction

A reference to a transaction.

The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See runTransaction.

class Transaction {
private constructor();
delete<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>): this;
get<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>;
set<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): this;
set<AppModelType, DbModelType extends DocumentData>(
documentRef: DocumentReference<AppModelType, DbModelType>,
data: PartialWithFieldValue<AppModelType>,
options: SetOptions,
): this;
update<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>, data: UpdateData<DbModelType>): this;
update<AppModelType, DbModelType extends DocumentData>(
documentRef: DocumentReference<AppModelType, DbModelType>,
field: string | FieldPath,
value: unknown,
...moreFieldsAndValues: unknown[],
): this;
}

§Constructors

§
new Transaction() private
[src]

§Methods

§
delete<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>): this
[src]

Deletes the document referred to by the provided DocumentReference.

@param documentRef
  • A reference to the document to be deleted.
@return

This Transaction instance. Used for chaining method calls.

§
get<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>
[src]

Reads the document referenced by the provided DocumentReference.

@param documentRef
  • A reference to the document to be read.
@return

A DocumentSnapshot with the read data.

§
set<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): this
[src]

Writes to the document referred to by the provided DocumentReference. If the document does not exist yet, it will be created.

@param documentRef
  • A reference to the document to be set.
@param data
  • An object of the fields and values for the document.
@return

This Transaction instance. Used for chaining method calls.

set<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>, data: PartialWithFieldValue<AppModelType>, options: SetOptions): this
[src]

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

@param documentRef
  • A reference to the document to be set.
@param data
  • An object of the fields and values for the document.
@param options
  • An object to configure the set behavior.
@return

This Transaction instance. Used for chaining method calls.

§
update<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>, data: UpdateData<DbModelType>): this
[src]

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

@param documentRef
  • A reference to the document to be updated.
@param data
  • An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document.
@return

This Transaction instance. Used for chaining method calls.

update<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): this
[src]

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

Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects.

@param documentRef
  • A reference to the document to be updated.
@param field
  • The first field to update.
@param value
  • The first value.
@param moreFieldsAndValues
  • Additional key/value pairs.
@return

This Transaction instance. Used for chaining method calls.