Transaction class

트랜잭션에 대한 참조입니다.

트랜잭션의 updateFunction에 전달되는 Transaction 객체는 트랜잭션 컨텍스트 내에서 데이터를 읽고 쓰는 메서드를 제공합니다. runTransaction()을 참조하세요.

서명:

export declare class Transaction 

메소드

메서드 특수키 설명
delete(documentRef) 제공된 DocumentReference에서 참조하는 문서를 삭제합니다.
get(documentRef) 제공된 DocumentReference로 참조되는 문서를 읽습니다.
set(documentRef, data) 제공된 DocumentReference로 참조되는 문서에 씁니다. 문서가 아직 없으면 새로 만듭니다.
set(documentRef, 데이터, 옵션) 제공된 DocumentReference로 참조되는 문서에 씁니다. 문서가 아직 없으면 새로 만듭니다. merge 또는 mergeFields를 제공하면 제공된 데이터를 기존 문서에 병합할 수 있습니다.
update(documentRef, data) 제공된 DocumentReference로 참조되는 문서의 필드를 업데이트합니다. 존재하지 않는 문서를 적용하면 업데이트가 실패합니다.
update(documentRef, field, value, moreFieldsAndValues) 제공된 DocumentReference로 참조되는 문서의 필드를 업데이트합니다. 존재하지 않는 문서를 적용하면 업데이트가 실패합니다.중첩된 필드는 점으로 구분된 필드 경로 문자열을 제공하거나 FieldPath 객체를 제공하여 업데이트할 수 있습니다.

Transaction.delete()

제공된 DocumentReference에서 참조하는 문서를 삭제합니다.

서명:

delete<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>): this;

매개변수

매개변수 유형 설명
문서 참조 DocumentReference<AppModelType, DBMModelType> 삭제할 문서에 대한 참조입니다.

반환:

Transaction 인스턴스 메서드 호출 체이닝에 사용됩니다.

Transaction.get()을 호출합니다.

제공된 DocumentReference로 참조되는 문서를 읽습니다.

서명:

get<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>;

매개변수

매개변수 유형 설명
문서 참조 DocumentReference<AppModelType, DBMModelType> 읽을 문서에 대한 참조입니다.

반환:

프로미스<DocumentSnapshot<AppModelType, DBMModelType>>

읽기 데이터가 있는 DocumentSnapshot

Transaction.set()

제공된 DocumentReference로 참조되는 문서에 씁니다. 문서가 아직 없으면 새로 만듭니다.

서명:

set<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): this;

매개변수

매개변수 유형 설명
문서 참조 DocumentReference<AppModelType, DBMModelType> 설정할 문서에 대한 참조입니다.
데이터 WithFieldValue<AppModelType> 문서의 필드 및 값의 객체입니다.

반환:

Transaction 인스턴스 메서드 호출 체이닝에 사용됩니다.

예외

오류 - 제공된 입력이 유효한 Firestore 문서가 아닌 경우

Transaction.set()

제공된 DocumentReference로 참조되는 문서에 씁니다. 문서가 아직 없으면 새로 만듭니다. merge 또는 mergeFields를 제공하면 제공된 데이터를 기존 문서에 병합할 수 있습니다.

서명:

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

매개변수

매개변수 유형 설명
문서 참조 DocumentReference<AppModelType, DBMModelType> 설정할 문서에 대한 참조입니다.
데이터 PartialWithFieldValue<AppModelType> 문서의 필드 및 값의 객체입니다.
옵션 SetOptions 집합 동작을 구성하는 객체입니다.

반환:

Transaction 인스턴스 메서드 호출 체이닝에 사용됩니다.

예외

오류 - 제공된 입력이 유효한 Firestore 문서가 아닌 경우

Transaction.update()

제공된 DocumentReference로 참조되는 문서의 필드를 업데이트합니다. 존재하지 않는 문서를 적용하면 업데이트가 실패합니다.

서명:

update<AppModelType, DbModelType extends DocumentData>(documentRef: DocumentReference<AppModelType, DbModelType>, data: UpdateData<DbModelType>): this;

매개변수

매개변수 유형 설명
문서 참조 DocumentReference<AppModelType, DBMModelType> 업데이트할 문서에 대한 참조입니다.
데이터 UpdateData<DbModelType> 문서를 업데이트할 필드와 값이 포함된 객체입니다. 필드에는 문서 내의 중첩된 필드를 참조하는 점이 포함될 수 있습니다.

반환:

Transaction 인스턴스 메서드 호출 체이닝에 사용됩니다.

예외

오류 - 제공된 입력이 유효한 Firestore 데이터가 아닌 경우

Transaction.update()

제공된 DocumentReference로 참조되는 문서의 필드를 업데이트합니다. 존재하지 않는 문서를 적용하면 업데이트가 실패합니다.

중첩된 필드는 점으로 구분된 필드 경로 문자열을 제공하거나 FieldPath 객체를 제공하여 업데이트할 수 있습니다.

서명:

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

매개변수

매개변수 유형 설명
문서 참조 DocumentReference<AppModelType, DBMModelType> 업데이트할 문서에 대한 참조입니다.
필드 문자열 | FieldPath 업데이트할 첫 번째 필드입니다.
알 수 없음 첫 번째 값입니다.
moreFieldsAndValues 알 수 없음[] 추가 키-값 쌍입니다.

반환:

Transaction 인스턴스 메서드 호출 체이닝에 사용됩니다.

예외

오류 - 제공된 입력이 유효한 Firestore 데이터가 아닌 경우