DocumentSnapshot class

DocumentSnapshot 에는 Firestore 데이터베이스의 문서에서 읽은 데이터가 포함됩니다. .data() 또는 .get(<field>) 사용하여 데이터를 추출하여 특정 필드를 가져올 수 있습니다.

존재하지 않는 문서를 가리키는 DocumentSnapshot 의 경우 모든 데이터 액세스는 '정의되지 않음'을 반환합니다. exists() 메소드를 사용하여 문서의 존재를 명시적으로 확인할 수 있습니다.

서명:

export declare class DocumentSnapshot<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> 

생성자

건설자 수정자 설명
(건설자)() DocumentSnapshot 클래스의 새 인스턴스를 생성합니다.

속성

재산 수정자 유형 설명
ID 문서의 ID를 제공하는 DocumentSnapshot 의 속성입니다.
심판 문서참조 <AppModelType, DbModelType> DocumentSnapshot 에 포함된 문서에 대한 DocumentReference .

행동 양식

방법 수정자 설명
데이터() 문서의 모든 필드를 Object 로 검색합니다. 문서가 존재하지 않으면 undefined 반환합니다.
존재합니다() 스냅샷 위치에 문서가 존재하는지 여부를 나타냅니다.
get(필드 경로) fieldPath 로 지정된 필드를 검색합니다. 문서나 필드가 없으면 undefined 반환합니다.

DocumentSnapshot.(생성자)

DocumentSnapshot 클래스의 새 인스턴스를 생성합니다.

서명:

protected constructor();

문서스냅샷.id

문서의 ID를 제공하는 DocumentSnapshot 의 속성입니다.

서명:

get id(): string;

문서스냅샷.ref

DocumentSnapshot 에 포함된 문서에 대한 DocumentReference .

서명:

get ref(): DocumentReference<AppModelType, DbModelType>;

DocumentSnapshot.data()

문서의 모든 필드를 Object 로 검색합니다. . 문서가 존재하지 않으면 undefined 반환합니다.

서명:

data(): AppModelType | undefined;

보고:

앱모델 유형 | 한정되지 않은

문서의 모든 필드를 포함하는 개체이거나 문서가 존재하지 않는 경우 undefined Object 입니다.

DocumentSnapshot.exists()

스냅샷 위치에 문서가 존재하는지 여부를 나타냅니다.

서명:

exists(): this is QueryDocumentSnapshot<AppModelType, DbModelType>;

보고:

이것은 QueryDocumentSnapshot 입니다. <AppModelType, DbModelType>

문서가 존재하면 true입니다.

DocumentSnapshot.get()

fieldPath 로 지정된 필드를 검색합니다. . 문서나 필드가 없으면 undefined 반환합니다.

서명:

get(fieldPath: string | FieldPath): any;

매개변수

매개변수 유형 설명
필드 경로 문자열 | 필드 경로 특정 필드에 대한 경로(예: 'foo' 또는 'foo.bar')입니다.

보고:

어느

지정된 필드 위치에 있는 데이터입니다. 문서에 해당 필드가 없으면 정의되지 않습니다.