https://github.com/kurotch321/firestore-controller
https://github.com/kurotch321/firestore-controller
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kurotch321/firestore-controller
- Owner: kurotch321
- Created: 2024-10-16T17:36:35.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-10-16T18:41:30.000Z (7 months ago)
- Last Synced: 2025-01-21T18:17:43.744Z (3 months ago)
- Language: TypeScript
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cloud Firestore Controller
This library makes it easy to operate the Cloud Firestore with short code.
## Requirements
- Node.js v20.0.0 or later
- [Cloud Firestore: Node.js Client (@google-cloud/firestore)](https://www.npmjs.com/package/@google-cloud/firestore) v7.0.0 or later## Example
### Read Document
Before:
```typescript
const doc = await firestore.collection("users").doc("user1").get();
const data = doc.data();console.log(data);
```After:
```typescript
const data = await readDoc("users", "user1");console.log(data);
```### Write Document
Before:
```typescript
const data = { name: "Alice", age: 20, email: "[email protected]" };await firestore.collection("users").doc("user1").set(data);
```After:
```typescript
const data = { name: "Alice", age: 20, email: "[email protected]" };await writeDoc("users", "user1", data);
```### Files
- [decodeServiceAccount.ts](./lib/decodeServiceAccount.ts) - Decode base64 encoded service account key.
- [firestoreController.ts](./lib/firestoreController.ts) - Main library file.