__CAPGO_KEEP_3__

시작하기

GitHub

설치

설치

AI-Assisted Setup을 사용하여 플러그인을 설치할 수 있습니다. Capgo 스킬을 AI 도구에 추가하려면 다음 명령어를 사용하세요:

터미널 창
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

그런 다음 다음 프롬프트를 사용하세요:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-firestore` plugin in my project.

만약 Manual Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요:

터미널 창
bun add @capgo/capacitor-firebase-firestore
npx cap sync
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';

빠른 시작

빠른 시작
import { plugin } from '@capgo/capacitor-firebase-firestore';
const result = await plugin.addDocument({
reference: 'users',
data: {},
});
console.log(result);

예시: addCollectionGroupSnapshotListener

예제: addCollectionGroupSnapshotListener
import { plugin } from '@capgo/capacitor-firebase-firestore';
const result = await plugin.addCollectionGroupSnapshotListener({ reference: 'reference' }, (event, error) => {
console.log(event);
});
console.log(result);

예시: addCollectionSnapshotListener

예제: addCollectionSnapshotListener 추가하기
import { plugin } from '@capgo/capacitor-firebase-firestore';
const result = await plugin.addCollectionSnapshotListener({ reference: 'reference' }, (event, error) => {
console.log(event);
});
console.log(result);

일반적인 함정

일반적인 함정
  • 네이티브 동기화: run npx cap sync 업그레이드 후 플러그인.
  • 실질적인 출처: 신뢰 src/definitions.ts GitHub 저장소에.

API 개요

API 개요

addDocument

addDocument

지정된 데이터와 함께 컬렉션에 새로운 문서를 추가합니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocument({} as AddDocumentOptions);

setDocument

__CAPGO_KEEP_0__

지정된 참조에 의해 참조되는 문서에 쓰는 것을 의미합니다. 만약 문서가 아직 존재하지 않으면 새로 생성됩니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.setDocument({} as SetDocumentOptions);

getDocument

getDocument

지정된 참조에 의해 참조되는 문서를 읽습니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getDocument({} as GetDocumentOptions);

updateDocument

업데이트 문서

지정된 참조에 의해 참조되는 문서의 필드를 업데이트합니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.updateDocument({} as UpdateDocumentOptions);

deleteDocument

deleteDocument

지정된 참조에 의해 참조되는 문서를 삭제합니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.deleteDocument({} as DeleteDocumentOptions);

writeBatch

writeBatch

여러 쓰기 작업을 단일 배치로 실행합니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.writeBatch({} as WriteBatchOptions);

getCollection

getCollection

지정된 참조에 의해 참조되는 컬렉션을 읽습니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollection({} as GetCollectionOptions);

getCollectionGroup

getCollectionGroup

지정된 참조에 의해 참조되는 컬렉션 그룹을 읽습니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollectionGroup({} as GetCollectionGroupOptions);

getCountFromServer

getCountFromServer

서버에서 문서의 수를 가져옵니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCountFromServer({} as GetCountFromServerOptions);

clearPersistence

clearPersistence

영구 저장소의 캐시 및 작성 중인 데이터를 삭제합니다.

앱이 종료되거나 앱이 처음 초기화될 때 호출해야 합니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.clearPersistence();

네트워크 사용을 재개합니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.enableNetwork();

네트워크 사용을 중단합니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.disableNetwork();

문서 스냅샷 이벤트에 대한 리스너를 추가합니다.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.useEmulator({} as UseEmulatorOptions);

addDocumentSnapshotListener

addDocumentSnapshotListener

Section titled “useEmulator”

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocumentSnapshotListener({} as AddDocumentSnapshotListenerOptions, {} as AddDocumentSnapshotListenerCallback<T>);

addCollectionSnapshotListener

컬렉션 스냅샷 리스너 추가

컬렉션 그룹 스냅샷 리스너 추가

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionSnapshotListener({} as AddCollectionSnapshotListenerOptions, {} as AddCollectionSnapshotListenerCallback<T>);

addCollectionGroupSnapshotListener

스냅샷 리스너 제거

이벤트 리스너

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionGroupSnapshotListener({} as AddCollectionGroupSnapshotListenerOptions, {} as AddCollectionGroupSnapshotListenerCallback<T>);

removeSnapshotListener

타입 참조

타입 참조

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.removeSnapshotListener({} as RemoveSnapshotListenerOptions);

타입 참조

타입 참조

AddDocumentOptions

AddDocumentOptions
export interface AddDocumentOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
* @example 'users'
*/
reference: string;
/**
* An object containing the data for the new document.
*
* @since 5.2.0
* @example { first: 'Alan', last: 'Turing', born: 1912 }
*/
data: DocumentData;
}

AddDocumentResult

AddDocumentResult
export interface AddDocumentResult {
/**
* The reference of the newly added document.
*
* @since 5.2.0
*/
reference: DocumentReference;
}

SetDocumentOptions

SetDocumentOptions
export interface SetDocumentOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
* @example 'users/Aorq09lkt1ynbR7xhTUx'
*/
reference: string;
/**
* An object containing the data for the new document.
*
* @since 5.2.0
* @example { first: 'Alan', last: 'Turing', born: 1912 }
*/
data: DocumentData;
/**
* Whether to merge the provided data with an existing document.
*
* @since 5.2.0
* @example true
* @default false
*/
merge?: boolean;
}

DocumentData

문서 데이터
export interface DocumentData {
/**
* A mapping between a field and its value.
*
* @since 5.2.0
*/
[field: string]: any;
}

GetDocumentOptions

GetDocumentOptions
export interface GetDocumentOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
*/
reference: string;
}

GetDocumentResult

GetDocumentResult
export interface GetDocumentResult<T> {
/**
* The current document contents.
*
* @since 5.2.0
*/
snapshot: DocumentSnapshot<T>;
}

UpdateDocumentOptions

업데이트 문서 옵션
export interface UpdateDocumentOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
*/
reference: string;
/**
* An object containing the data for the new document.
*
* @since 5.2.0
* @example { first: 'Alan', last: 'Turing', born: 1912 }
*/
data: DocumentData;
}

DeleteDocumentOptions

삭제 문서 옵션
export interface DeleteDocumentOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
*/
reference: string;
}

WriteBatchOptions

쓰기 배치 옵션
export interface WriteBatchOptions {
/**
* The operations to execute in the batch.
*
* @since 6.1.0
*/
operations: WriteBatchOperation[];
}

GetCollectionOptions

컬렉션 가져오기 옵션
export interface GetCollectionOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
*/
reference: string;
/**
* The filter to apply.
*
* @since 5.2.0
*/
compositeFilter?: QueryCompositeFilterConstraint;
/**
* Narrow or order the set of documents to retrieve, but do not explicitly filter for document fields.
*
* @since 5.2.0
*/
queryConstraints?: QueryNonFilterConstraint[];
}
export interface GetCollectionResult<T> {
/**
* The documents in the collection.
*
* @since 5.2.0
*/
snapshots: DocumentSnapshot<T>[];
}

GetCollectionGroupOptions

컬렉션 그룹 가져오기 옵션
export interface GetCollectionGroupOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
*/
reference: string;
/**
* The filter to apply.
*
* @since 5.2.0
*/
compositeFilter?: QueryCompositeFilterConstraint;
/**
* Narrow or order the set of documents to retrieve, but do not explicitly filter for document fields.
*
* @since 5.2.0
*/
queryConstraints?: QueryNonFilterConstraint[];
}

이 페이지는 플러그인의 src/definitions.ts. upstream에서 변경된 경우 pubic API 다시 싱크를 실행하세요.

이러한 플러그인을 사용하는 경우 시작하기 계획 대시보드 및 API 운영을 계획하는 경우 API 개요 API 개요에서 API 구현 세부 정보를 확인하세요. 소개 소개에서 구현 세부 정보를 위해 API 키 API 키에서 구현 세부 정보를 위해 장치 소개에서 구현 세부 정보를 위해 장치, 그리고 패키지 소개에서 구현 세부 정보를 위해 패키지.