# @firebaseasy/firestore 中文文档

规范地址：https://npmcn.com/package/%40firebaseasy/firestore/

版本：1\.0\.7
npm 元数据更新时间：2025-02-19T12:34:54.516Z
中文译文更新时间：2026-11-14T19:27:20.365Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40firebaseasy/firestore
原文对照：https://npmcn.com/package/%40firebaseasy/firestore/?lang=original
项目主页：https://github.com/91nakashima/firebaseasy
源码仓库：https://github.com/91nakashima/firebaseasy#main

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：49.5 kB，62 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：3 个
- 首次发布：2022-03-05T01:21:42.316Z
- 最新版本发布：2025-02-19T12:34:54.349Z
- 近 30 天下载量：3769（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：42（近 12 个月 0 个）

## 中文简介

易用火炉

## 安装

```sh
npm install @firebaseasy/firestore
```

也可以使用：`pnpm add @firebaseasy/firestore`、`yarn add @firebaseasy/firestore`、`bun add @firebaseasy/firestore`

## README

# 火灾

中岛软件包管理器 时间轴:。

```bash
npm i @firebaseasy/firestore
```

# 使い方

```js
import { easySetDoc } from '@firebaseasy/firestore'
import { easyGetData, easyGetDoc, easyGetDocs } from '@firebaseasy/firestore'
import { easyDelDoc } from '@firebaseasy/firestore'

// Type
import { EasySetDoc, QueryOption, WhereOption } from '@firebaseasy/firestore'

// ↓only browser
import { easyConnect, easyUnConnect } from '@firebaseasy/firestore'
import { createRef } from '@firebaseasy/firestore'
export { isTypeCollectionOrQuery } from './helpers/checkType'
```

# {\\fn华文楷体\\fs16\\1cHE0E0E0}

```js
import { initializeApp } from 'firebase/app'
import { getFirestore } from 'firebase/firestore'
import { easyConnect } from '@firebaseasy/firestore'

const app = initializeApp({
  apiKey: '### FIREBASE API KEY ###',
  authDomain: '### FIREBASE AUTH DOMAIN ###',
  projectId: '### CLOUD FIRESTORE PROJECT ID ###'
})

export const firestore = getFirestore(app)

export const userEasy = easyConnect(firestore, 'User')
// userEasy.set({name: 'naruto'})
// userEasy.sbscribe()
// userEasy.unsbscribe()
```

# 機能

作成したドキュメント(フィールド)に自動追加されます。

```js
// set
{
  id: string // document id
}
```

医生 `id` 身份证明。

```js
import { firestore } from 'initfirebase'
import { easySetDoc } from '@firebaseasy/firestore'

// create
easySetDoc(firestore, 'anime', {
  title: 'NARUTO',
  character: ['Naruto', 'Sasuke', 'Sakura']
})

// update or create(add)
easySetDoc(firestore, 'anime/abcde/animeDetail', {
  id: 'fghijklmno'
  title: 'NARUTO',
  character: ['Naruto', 'Sasuke', 'Sakura'],
})
// ↑ same ↓
easySetDoc(firestore, 'anime/abcde/animeDetail/fghijklmno', {
  title: 'NARUTO',
  character: ['Naruto', 'Sasuke', 'Sakura'],
})

// Error()
easySetDoc(firestore, 'anime/abcdefghijklmnopqrstuvwxyz', {
  id: 'zyxwvutsrqponmlkjihgfedcba'
  title: 'NARUTO',
  character: ['Naruto', 'Sasuke', 'Sakura']
})

// If you only want to use a setDoc().
easySetDoc(firestore, 'anime/abcdefghijklmnopqrstuvwxyz', {
  id: 'zyxwvutsrqponmlkjihgfedcba'
  title: 'NARUTO',
  character: ['Naruto', 'Sasuke', 'Sakura']
}, { marge: false })
```

情報の取得ができます。

```js
import { firestore } from 'initfirebase'

// get Collection data as an Array
/** @return {array<T>} */
easyGetData(firestore, 'anime', {
  where: [['title', '==', 'NARUTO'], ['character', 'array-contains', 'Sasuke']],
  orderBy: ['created_at']
  limit: 99,
})
easyGetData(firestore, 'anime', {
  where: [['title', '==', 'NARUTO'], ['character', 'array-contains', 'Sasuke']],
  orderBy: [['created_at', 'desc']]
  limit: 99,
})

// get document data as an Object
/** @return {Objrct | undefined} */
easyGetData(firestore, 'anime/abcdefghijklmnopqrstuvwxyz')

/** @return {Promise<T[] | T | undefined>} */
easyGetData(firestore, 'anime/abcdefghijklmnopqrstuvwxyz')

/** @return {Promise<T | undefined>} */
easyGetDoc(firestore, 'anime/abcdefg')

/** @return {Promise<T[]>} */
easyGetDocs(firestore, 'anime')
```

情報の削除

```js
import { firestore } from 'initfirebase'

// delete document
easyDelDoc(firestore, 'anime/abcdefghijklmnopqrstuvwxyz')
```

使用简单连接样本代码

```js
import { easyConnect } from '@firebaseasy/firestore'
import { firestore } from 'initfirebase'
export const showUserData = easyConnect(firestore, 'D_ShowUser')
// export const showUserData = easyConnect('D_ShowUser/xxxxxxxxxx')

// ↓different file↓
import { showUserData } from './index'
const showUserArray = computed(() => {
  return Array.from(showUserData.data.values())
})
```

Vuex 样本代码

```js
import { easyConnect } from '@firebaseasy/firestore'
import { CollectionReference } from 'firebase/firestore'
import { firestore } from 'initfirebase'

const collectionName = 'ShowUser'

function initialState () {
  return {
    data: {} // firestore data
  }
}

export default {
  namespaced: true,
  state: initialState(),

  getters: {
    getShowUser: (state: any) => state.data
  },

  mutations: {
    initData<T> (state: any, value: T) {
      state.data = value
    }
  },

  actions: {
    async getDocs ({ dispatch, rootState, state, commit }: any): Promise<void> {
      easyConnect(firestore, collectionName).subscribe(snapshot => {
        commit('initData', snapshot)
      })
    }
  }
}
```

## 常见问题

### @firebaseasy/firestore 是什么？

易用火炉

### 如何安装 @firebaseasy/firestore？

在项目目录运行 npm install @firebaseasy/firestore，或使用 pnpm add / yarn add / bun add。

### @firebaseasy/firestore 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @firebaseasy/firestore 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @firebaseasy/firestore 可以商用吗？

@firebaseasy/firestore 使用 ISC 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @firebaseasy/firestore 的下载量有多少？

根据 npm 官方下载统计，@firebaseasy/firestore 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,769 次，日均约 126 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @firebaseasy/firestore 还在维护吗？

最新版本 1\.0\.7 发布于 2025/02/19（1\.7 年前）；至今共发布 42 个版本，其中过去 12 个月发布了 0 个；首次发布于 2022/03/05。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

