@firestore-repository/firebase-js-sdk 0.2.1 → 0.3.0

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.
@@ -1,5 +1,5 @@
1
1
  import { type DocumentReference, type DocumentSnapshot, type Firestore, type Query as FirestoreQuery, Transaction, type WriteBatch } from '@firebase/firestore';
2
- import type { AggregateQuery, Aggregated } from 'firestore-repository/aggregate';
2
+ import type { AggregateSpec, Aggregated } from 'firestore-repository/aggregate';
3
3
  import type { WriteDocumentData } from 'firestore-repository/document';
4
4
  import type { Query } from 'firestore-repository/query';
5
5
  import type * as repository from 'firestore-repository/repository';
@@ -19,7 +19,7 @@ export declare class Repository<T extends CollectionSchema = CollectionSchema> i
19
19
  getOnSnapshot(id: Id<T>, next: (snapshot: Model<T> | undefined) => void, error?: (error: Error) => void, complete?: () => void): repository.Unsubscribe;
20
20
  list(query: Query<T>): Promise<Model<T>[]>;
21
21
  listOnSnapshot(query: Query<T>, next: (snapshot: Model<T>[]) => void, error?: (error: Error) => void, complete?: () => void): repository.Unsubscribe;
22
- aggregate<U extends AggregateQuery<T>>(aggregate: U): Promise<Aggregated<U>>;
22
+ aggregate<U extends AggregateSpec<T>>(query: Query<T>, spec: U): Promise<Aggregated<U>>;
23
23
  set(doc: Model<T>, options?: WriteTransactionOption): Promise<void>;
24
24
  delete(id: Id<T>, options?: WriteTransactionOption): Promise<void>;
25
25
  batchSet(docs: Model<T>[], options?: WriteTransactionOption): Promise<void>;
@@ -41,9 +41,9 @@ export class Repository {
41
41
  },
42
42
  });
43
43
  }
44
- async aggregate(aggregate) {
44
+ async aggregate(query, spec) {
45
45
  const aggregateSpec = {};
46
- for (const [k, v] of Object.entries(aggregate.spec)) {
46
+ for (const [k, v] of Object.entries(spec)) {
47
47
  switch (v.kind) {
48
48
  case 'count':
49
49
  aggregateSpec[k] = count();
@@ -58,7 +58,7 @@ export class Repository {
58
58
  return assertNever(v);
59
59
  }
60
60
  }
61
- const res = await getAggregateFromServer(toFirestoreQuery(this.db, aggregate.query), aggregateSpec);
61
+ const res = await getAggregateFromServer(toFirestoreQuery(this.db, query), aggregateSpec);
62
62
  return res.data();
63
63
  }
64
64
  async set(doc, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestore-repository/firebase-js-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
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
  "@firebase/firestore": "^4.7.5",
13
- "firestore-repository": "0.2.1"
13
+ "firestore-repository": "0.3.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@firebase/app": "^0.10.16"