@firestore-repository/google-cloud-firestore 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +17 -14
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -9,7 +9,8 @@ A minimum and universal Firestore ORM (Repository Pattern) for TypeScript
9
9
  ## Features
10
10
 
11
11
  - 🚀 **Minimum**: Only a few straightforward interfaces and classes. You can easily start to use it immediately without learning a lot of things.
12
- - 🌐 **Unopinionated**: This library does not introduce any additional concepts, and respects an interface of the official Firestore client library.
12
+ - 🌐 **Universal**: You can share most code, including schema and query definitions, between backend and frontend.
13
+ - 🤝 **Unopinionated**: This library does not introduce any additional concepts, and respects vocabulary of the official Firestore client library.
13
14
  - ✅ **Type-safe**: This library provides the type-safe interface. It also covers the untyped parts of the official Firestore library.
14
15
  - 🗄️ **Repository Pattern**: A simple and consistent way to access Firestore data.
15
16
 
@@ -90,28 +91,30 @@ await repository.delete({ userId: 'user2' });
90
91
  ### Query
91
92
 
92
93
  ```ts
93
- import { condition as $, limit, query, where } from 'firestore-repository/query';
94
+ import { condition as $, limit, query } from 'firestore-repository/query';
94
95
 
95
96
  // Define a query
96
- const query1 = query(users, $('profile.age', '>=', 20), limit(10));
97
+ const q = query(
98
+ users,
99
+ $('profile.age', '>=', 20),
100
+ $('profile.gender', '==', 'male'),
101
+ limit(10),
102
+ );
97
103
 
98
104
  // List documents
99
- const docs = await repository.list(query1);
105
+ const docs = await repository.list(q);
100
106
  console.log(docs);
101
107
 
102
108
  // Listen documents
103
- repository.listOnSnapshot(query1, (docs) => {
109
+ repository.listOnSnapshot(q, (docs) => {
104
110
  console.log(docs);
105
111
  });
106
112
 
107
113
  // Aggregate
108
- const result = await repository.aggregate({
109
- query: query1,
110
- spec: {
111
- avgAge: average('profile.age'),
112
- sumAge: sum('profile.age'),
113
- count: count(),
114
- },
114
+ const result = await repository.aggregate(q, {
115
+ avgAge: average('profile.age'),
116
+ sumAge: sum('profile.age'),
117
+ count: count(),
115
118
  });
116
119
  console.log(`avg:${result.avgAge} sum:${result.sumAge} count:${result.count}`);
117
120
  ```
@@ -188,12 +191,12 @@ await runTransaction(async (tx) => {
188
191
  await repository.batchSet([
189
192
  { ...doc, userId: 'user2' },
190
193
  { ...doc, userId: 'user3' },
191
- ]);
194
+ ], { tx });
192
195
  }
193
196
 
194
197
  // Delete
195
198
  await repository.delete({ userId: 'user4' }, { tx });
196
- await repository.batchDelete([{ userId: 'user5' }, { userId: 'user6' }]);
199
+ await repository.batchDelete([{ userId: 'user5' }, { userId: 'user6' }], { tx });
197
200
  });
198
201
  ```
199
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestore-repository/google-cloud-firestore",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "A minimum and universal Firestore ORM (Repository Pattern) for TypeScript",
5
5
  "homepage": "https://github.com/ikenox/firestore-repository",
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  "type": "module",
11
11
  "dependencies": {
12
12
  "@google-cloud/firestore": "^7.10.0",
13
- "firestore-repository": "0.4.1"
13
+ "firestore-repository": "0.4.2"
14
14
  },
15
15
  "exports": {
16
16
  ".": {