shelving 1.76.2 → 1.79.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.
- package/{api → modules/api}/Resource.d.ts +0 -0
- package/{api → modules/api}/Resource.js +0 -0
- package/{api → modules/api}/index.d.ts +0 -0
- package/{api → modules/api}/index.js +0 -0
- package/{constraint → modules/constraint}/Constraint.d.ts +0 -0
- package/{constraint → modules/constraint}/Constraint.js +0 -0
- package/{constraint → modules/constraint}/Constraints.d.ts +1 -1
- package/{constraint → modules/constraint}/Constraints.js +0 -0
- package/{constraint → modules/constraint}/FilterConstraint.d.ts +6 -6
- package/{constraint → modules/constraint}/FilterConstraint.js +1 -1
- package/{constraint → modules/constraint}/FilterConstraints.d.ts +5 -5
- package/{constraint → modules/constraint}/FilterConstraints.js +0 -0
- package/{constraint → modules/constraint}/QueryConstraints.d.ts +4 -4
- package/{constraint → modules/constraint}/QueryConstraints.js +2 -2
- package/{constraint → modules/constraint}/SortConstraint.d.ts +4 -3
- package/{constraint → modules/constraint}/SortConstraint.js +2 -3
- package/{constraint → modules/constraint}/SortConstraints.d.ts +5 -5
- package/{constraint → modules/constraint}/SortConstraints.js +0 -0
- package/{constraint → modules/constraint}/index.d.ts +0 -0
- package/{constraint → modules/constraint}/index.js +0 -0
- package/{db → modules/db}/Change.d.ts +10 -13
- package/{db → modules/db}/Change.js +2 -2
- package/modules/db/Collection.d.ts +74 -0
- package/{db → modules/db}/Collection.js +47 -7
- package/modules/db/Database.d.ts +76 -0
- package/modules/db/Database.js +95 -0
- package/{db → modules/db}/Item.d.ts +9 -9
- package/{db → modules/db}/Item.js +19 -21
- package/{db → modules/db}/Query.d.ts +6 -6
- package/{db → modules/db}/Query.js +2 -3
- package/{db → modules/db}/index.d.ts +0 -0
- package/{db → modules/db}/index.js +0 -0
- package/{error → modules/error}/AssertionError.d.ts +0 -0
- package/{error → modules/error}/AssertionError.js +0 -0
- package/{error → modules/error}/ConditionError.d.ts +0 -0
- package/{error → modules/error}/ConditionError.js +0 -0
- package/{error → modules/error}/PermissionError.d.ts +0 -0
- package/{error → modules/error}/PermissionError.js +0 -0
- package/{error → modules/error}/RequiredError.d.ts +0 -0
- package/{error → modules/error}/RequiredError.js +0 -0
- package/{error → modules/error}/ThroughError.d.ts +0 -0
- package/{error → modules/error}/ThroughError.js +0 -0
- package/{error → modules/error}/UnsupportedError.d.ts +0 -0
- package/{error → modules/error}/UnsupportedError.js +0 -0
- package/{error → modules/error}/ValidationError.d.ts +0 -0
- package/{error → modules/error}/ValidationError.js +0 -0
- package/{error → modules/error}/index.d.ts +0 -0
- package/{error → modules/error}/index.js +0 -0
- package/{feedback → modules/feedback}/ErrorFeedback.d.ts +0 -0
- package/{feedback → modules/feedback}/ErrorFeedback.js +1 -5
- package/{feedback → modules/feedback}/Feedback.d.ts +0 -0
- package/{feedback → modules/feedback}/Feedback.js +1 -5
- package/{feedback → modules/feedback}/InvalidFeedback.d.ts +0 -0
- package/{feedback → modules/feedback}/InvalidFeedback.js +1 -5
- package/{feedback → modules/feedback}/SuccessFeedback.d.ts +0 -0
- package/{feedback → modules/feedback}/SuccessFeedback.js +1 -5
- package/{feedback → modules/feedback}/WarningFeedback.d.ts +0 -0
- package/{feedback → modules/feedback}/WarningFeedback.js +1 -5
- package/{feedback → modules/feedback}/hydrations.d.ts +0 -0
- package/{feedback → modules/feedback}/hydrations.js +0 -0
- package/{feedback → modules/feedback}/index.d.ts +0 -0
- package/{feedback → modules/feedback}/index.js +0 -0
- package/{firestore → modules/firestore}/client/FirestoreClientProvider.d.ts +3 -3
- package/{firestore → modules/firestore}/client/FirestoreClientProvider.js +4 -4
- package/{firestore → modules/firestore}/client/index.d.ts +0 -0
- package/{firestore → modules/firestore}/client/index.js +0 -0
- package/{firestore → modules/firestore}/lite/FirestoreLiteProvider.d.ts +3 -3
- package/{firestore → modules/firestore}/lite/FirestoreLiteProvider.js +4 -4
- package/{firestore → modules/firestore}/lite/index.d.ts +0 -0
- package/{firestore → modules/firestore}/lite/index.js +0 -0
- package/{firestore → modules/firestore}/server/FirestoreServerProvider.d.ts +3 -3
- package/{firestore → modules/firestore}/server/FirestoreServerProvider.js +4 -4
- package/{firestore → modules/firestore}/server/index.d.ts +0 -0
- package/{firestore → modules/firestore}/server/index.js +0 -0
- package/{index.d.ts → modules/index.d.ts} +0 -0
- package/{index.js → modules/index.js} +0 -0
- package/{markup → modules/markup}/index.d.ts +0 -0
- package/{markup → modules/markup}/index.js +0 -0
- package/{markup → modules/markup}/options.d.ts +0 -0
- package/{markup → modules/markup}/options.js +0 -0
- package/{markup → modules/markup}/regexp.d.ts +0 -0
- package/{markup → modules/markup}/regexp.js +0 -0
- package/{markup → modules/markup}/render.d.ts +0 -0
- package/{markup → modules/markup}/render.js +0 -0
- package/{markup → modules/markup}/rules.d.ts +0 -0
- package/{markup → modules/markup}/rules.js +0 -0
- package/{observe → modules/observe}/AbstractObserver.d.ts +0 -0
- package/{observe → modules/observe}/AbstractObserver.js +0 -0
- package/{observe → modules/observe}/AsyncObserver.d.ts +0 -0
- package/{observe → modules/observe}/AsyncObserver.js +0 -0
- package/{observe → modules/observe}/LastSubject.d.ts +0 -0
- package/{observe → modules/observe}/LastSubject.js +0 -0
- package/{observe → modules/observe}/MatchObserver.d.ts +0 -0
- package/{observe → modules/observe}/MatchObserver.js +0 -0
- package/{observe → modules/observe}/MatchableObserver.d.ts +0 -0
- package/{observe → modules/observe}/MatchableObserver.js +0 -0
- package/{observe → modules/observe}/Observable.d.ts +0 -0
- package/{observe → modules/observe}/Observable.js +0 -0
- package/{observe → modules/observe}/Observer.d.ts +0 -0
- package/{observe → modules/observe}/Observer.js +0 -0
- package/{observe → modules/observe}/OnceObserver.d.ts +0 -0
- package/{observe → modules/observe}/OnceObserver.js +0 -0
- package/{observe → modules/observe}/Subject.d.ts +0 -0
- package/{observe → modules/observe}/Subject.js +0 -0
- package/{observe → modules/observe}/ThroughObserver.d.ts +0 -0
- package/{observe → modules/observe}/ThroughObserver.js +0 -0
- package/{observe → modules/observe}/TransformObserver.d.ts +0 -0
- package/{observe → modules/observe}/TransformObserver.js +0 -0
- package/{observe → modules/observe}/TransformableObserver.d.ts +0 -0
- package/{observe → modules/observe}/TransformableObserver.js +0 -0
- package/{observe → modules/observe}/index.d.ts +0 -0
- package/{observe → modules/observe}/index.js +0 -0
- package/{observe → modules/observe}/util.d.ts +0 -0
- package/{observe → modules/observe}/util.js +0 -0
- package/{provider → modules/provider}/BatchProvider.d.ts +0 -0
- package/{provider → modules/provider}/BatchProvider.js +0 -0
- package/{provider → modules/provider}/CacheProvider.d.ts +3 -3
- package/{provider → modules/provider}/CacheProvider.js +6 -6
- package/{provider → modules/provider}/DebugProvider.d.ts +5 -5
- package/{provider → modules/provider}/DebugProvider.js +12 -12
- package/{provider → modules/provider}/MemoryProvider.d.ts +5 -5
- package/{provider → modules/provider}/MemoryProvider.js +9 -8
- package/{provider → modules/provider}/Provider.d.ts +7 -7
- package/{provider → modules/provider}/Provider.js +0 -0
- package/{provider → modules/provider}/ThroughProvider.d.ts +5 -5
- package/{provider → modules/provider}/ThroughProvider.js +4 -4
- package/{provider → modules/provider}/ValidationProvider.d.ts +11 -11
- package/{provider → modules/provider}/ValidationProvider.js +29 -28
- package/{provider → modules/provider}/index.d.ts +0 -0
- package/{provider → modules/provider}/index.js +0 -0
- package/{react → modules/react}/index.d.ts +0 -0
- package/{react → modules/react}/index.js +0 -0
- package/{react → modules/react}/useCache.d.ts +0 -0
- package/{react → modules/react}/useCache.js +0 -0
- package/{react → modules/react}/useInstance.d.ts +0 -0
- package/{react → modules/react}/useInstance.js +0 -0
- package/{react → modules/react}/useItem.d.ts +7 -7
- package/{react → modules/react}/useItem.js +0 -0
- package/{react → modules/react}/useLazy.d.ts +0 -0
- package/{react → modules/react}/useLazy.js +0 -0
- package/{react → modules/react}/useQuery.d.ts +10 -10
- package/{react → modules/react}/useQuery.js +0 -0
- package/{react → modules/react}/useReduce.d.ts +0 -0
- package/{react → modules/react}/useReduce.js +0 -0
- package/{react → modules/react}/useSubscribe.d.ts +0 -0
- package/{react → modules/react}/useSubscribe.js +0 -0
- package/{schema → modules/schema}/AllowSchema.d.ts +0 -0
- package/{schema → modules/schema}/AllowSchema.js +0 -0
- package/{schema → modules/schema}/ArraySchema.d.ts +0 -0
- package/{schema → modules/schema}/ArraySchema.js +0 -0
- package/{schema → modules/schema}/BooleanSchema.d.ts +0 -0
- package/{schema → modules/schema}/BooleanSchema.js +0 -0
- package/{schema → modules/schema}/ColorSchema.d.ts +0 -0
- package/{schema → modules/schema}/ColorSchema.js +0 -0
- package/{schema → modules/schema}/DataSchema.d.ts +5 -1
- package/{schema → modules/schema}/DataSchema.js +0 -0
- package/{schema → modules/schema}/DateSchema.d.ts +0 -0
- package/{schema → modules/schema}/DateSchema.js +0 -0
- package/{schema → modules/schema}/EmailSchema.d.ts +0 -0
- package/{schema → modules/schema}/EmailSchema.js +0 -0
- package/{schema → modules/schema}/KeySchema.d.ts +0 -0
- package/{schema → modules/schema}/KeySchema.js +0 -0
- package/{schema → modules/schema}/LinkSchema.d.ts +0 -0
- package/{schema → modules/schema}/LinkSchema.js +0 -0
- package/{schema → modules/schema}/NumberSchema.d.ts +0 -0
- package/{schema → modules/schema}/NumberSchema.js +0 -0
- package/{schema → modules/schema}/ObjectSchema.d.ts +0 -0
- package/{schema → modules/schema}/ObjectSchema.js +0 -0
- package/{schema → modules/schema}/OptionalSchema.d.ts +0 -0
- package/{schema → modules/schema}/OptionalSchema.js +0 -0
- package/{schema → modules/schema}/PhoneSchema.d.ts +0 -0
- package/{schema → modules/schema}/PhoneSchema.js +0 -0
- package/{schema → modules/schema}/RequiredSchema.d.ts +0 -0
- package/{schema → modules/schema}/RequiredSchema.js +0 -0
- package/{schema → modules/schema}/Schema.d.ts +0 -0
- package/{schema → modules/schema}/Schema.js +0 -0
- package/{schema → modules/schema}/SlugSchema.d.ts +0 -0
- package/{schema → modules/schema}/SlugSchema.js +0 -0
- package/{schema → modules/schema}/StringSchema.d.ts +0 -0
- package/{schema → modules/schema}/StringSchema.js +0 -0
- package/{schema → modules/schema}/ThroughSchema.d.ts +0 -0
- package/{schema → modules/schema}/ThroughSchema.js +0 -0
- package/{schema → modules/schema}/index.d.ts +0 -0
- package/{schema → modules/schema}/index.js +0 -0
- package/{state → modules/state}/ArrayState.d.ts +0 -0
- package/{state → modules/state}/ArrayState.js +0 -0
- package/{state → modules/state}/BooleanState.d.ts +0 -0
- package/{state → modules/state}/BooleanState.js +0 -0
- package/{state → modules/state}/DataState.d.ts +3 -3
- package/{state → modules/state}/DataState.js +0 -0
- package/{state → modules/state}/ObjectState.d.ts +0 -0
- package/{state → modules/state}/ObjectState.js +0 -0
- package/{state → modules/state}/SelfClosingState.d.ts +0 -0
- package/{state → modules/state}/SelfClosingState.js +0 -0
- package/{state → modules/state}/State.d.ts +0 -0
- package/{state → modules/state}/State.js +0 -0
- package/{state → modules/state}/index.d.ts +0 -0
- package/{state → modules/state}/index.js +0 -0
- package/{test → modules/test}/basics.d.ts +0 -0
- package/{test → modules/test}/basics.js +0 -0
- package/{test → modules/test}/index.d.ts +0 -0
- package/{test → modules/test}/index.js +0 -0
- package/{test → modules/test}/people.d.ts +0 -0
- package/{test → modules/test}/people.js +0 -0
- package/{test → modules/test}/util.d.ts +0 -0
- package/{test → modules/test}/util.js +0 -0
- package/{update → modules/update}/ArrayUpdate.d.ts +0 -0
- package/{update → modules/update}/ArrayUpdate.js +0 -0
- package/{update → modules/update}/DataUpdate.d.ts +15 -7
- package/{update → modules/update}/DataUpdate.js +28 -21
- package/{update → modules/update}/Delete.d.ts +0 -0
- package/{update → modules/update}/Delete.js +0 -0
- package/{update → modules/update}/Increment.d.ts +0 -0
- package/{update → modules/update}/Increment.js +0 -0
- package/{update → modules/update}/ObjectUpdate.d.ts +0 -0
- package/{update → modules/update}/ObjectUpdate.js +0 -0
- package/{update → modules/update}/Update.d.ts +0 -0
- package/{update → modules/update}/Update.js +0 -0
- package/{update → modules/update}/hydrations.d.ts +0 -0
- package/{update → modules/update}/hydrations.js +0 -0
- package/{update → modules/update}/index.d.ts +0 -0
- package/{update → modules/update}/index.js +0 -0
- package/{util → modules/util}/array.d.ts +0 -0
- package/{util → modules/util}/array.js +0 -0
- package/{util → modules/util}/assert.d.ts +0 -0
- package/{util → modules/util}/assert.js +0 -0
- package/{util → modules/util}/async.d.ts +0 -0
- package/{util → modules/util}/async.js +0 -0
- package/{util → modules/util}/boolean.d.ts +0 -0
- package/{util → modules/util}/boolean.js +0 -0
- package/{util → modules/util}/class.d.ts +0 -0
- package/{util → modules/util}/class.js +0 -0
- package/{util → modules/util}/clone.d.ts +0 -0
- package/{util → modules/util}/clone.js +0 -0
- package/{util → modules/util}/color.d.ts +0 -0
- package/{util → modules/util}/color.js +0 -0
- package/{util → modules/util}/data.d.ts +0 -0
- package/{util → modules/util}/data.js +0 -0
- package/{util → modules/util}/date.d.ts +0 -0
- package/{util → modules/util}/date.js +0 -0
- package/{util → modules/util}/debug.d.ts +0 -0
- package/{util → modules/util}/debug.js +0 -0
- package/{util → modules/util}/diff.d.ts +0 -0
- package/{util → modules/util}/diff.js +0 -0
- package/{util → modules/util}/entry.d.ts +0 -0
- package/{util → modules/util}/entry.js +0 -0
- package/{util → modules/util}/equal.d.ts +0 -0
- package/{util → modules/util}/equal.js +0 -0
- package/{util → modules/util}/error.d.ts +0 -0
- package/{util → modules/util}/error.js +0 -0
- package/{util → modules/util}/filter.d.ts +0 -0
- package/{util → modules/util}/filter.js +0 -0
- package/{util → modules/util}/function.d.ts +0 -0
- package/{util → modules/util}/function.js +0 -0
- package/{util → modules/util}/hydrate.d.ts +0 -0
- package/{util → modules/util}/hydrate.js +0 -0
- package/{util → modules/util}/index.d.ts +0 -0
- package/{util → modules/util}/index.js +0 -0
- package/{util → modules/util}/iterate.d.ts +0 -0
- package/{util → modules/util}/iterate.js +0 -0
- package/{util → modules/util}/jsx.d.ts +0 -0
- package/{util → modules/util}/jsx.js +0 -0
- package/{util → modules/util}/lazy.d.ts +0 -0
- package/{util → modules/util}/lazy.js +0 -0
- package/{util → modules/util}/map.d.ts +0 -0
- package/{util → modules/util}/map.js +0 -0
- package/{util → modules/util}/match.d.ts +0 -0
- package/{util → modules/util}/match.js +0 -0
- package/{util → modules/util}/merge.d.ts +0 -0
- package/{util → modules/util}/merge.js +0 -0
- package/{util → modules/util}/null.d.ts +0 -0
- package/{util → modules/util}/null.js +0 -0
- package/{util → modules/util}/number.d.ts +0 -0
- package/{util → modules/util}/number.js +0 -0
- package/{util → modules/util}/object.d.ts +0 -0
- package/{util → modules/util}/object.js +0 -0
- package/{util → modules/util}/random.d.ts +0 -0
- package/{util → modules/util}/random.js +0 -0
- package/{util → modules/util}/regexp.d.ts +0 -0
- package/{util → modules/util}/regexp.js +0 -0
- package/{util → modules/util}/serialise.d.ts +0 -0
- package/{util → modules/util}/serialise.js +0 -0
- package/{util → modules/util}/set.d.ts +0 -0
- package/{util → modules/util}/set.js +0 -0
- package/{util → modules/util}/sort.d.ts +0 -0
- package/{util → modules/util}/sort.js +0 -0
- package/{util → modules/util}/source.d.ts +0 -0
- package/{util → modules/util}/source.js +0 -0
- package/{util → modules/util}/string.d.ts +0 -0
- package/{util → modules/util}/string.js +0 -0
- package/{util → modules/util}/template.d.ts +0 -0
- package/{util → modules/util}/template.js +0 -0
- package/{util → modules/util}/timeout.d.ts +0 -0
- package/{util → modules/util}/timeout.js +0 -0
- package/{util → modules/util}/transform.d.ts +3 -3
- package/{util → modules/util}/transform.js +0 -0
- package/{util → modules/util}/undefined.d.ts +0 -0
- package/{util → modules/util}/undefined.js +0 -0
- package/{util → modules/util}/units.d.ts +0 -0
- package/{util → modules/util}/units.js +0 -0
- package/{util → modules/util}/url.d.ts +0 -0
- package/{util → modules/util}/url.js +0 -0
- package/{util → modules/util}/validate.d.ts +0 -0
- package/{util → modules/util}/validate.js +0 -0
- package/package.json +8 -8
- package/db/Collection.d.ts +0 -46
- package/db/Database.d.ts +0 -42
- package/db/Database.js +0 -43
|
@@ -3,7 +3,7 @@ import type { Dispatch } from "../util/function.js";
|
|
|
3
3
|
import type { PartialObserver } from "../observe/Observer.js";
|
|
4
4
|
import type { ImmutableArray } from "../util/array.js";
|
|
5
5
|
import type { Observable, Unsubscribe } from "../observe/Observable.js";
|
|
6
|
-
import { DataUpdate,
|
|
6
|
+
import { DataUpdate, Updates } from "../update/DataUpdate.js";
|
|
7
7
|
import type { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
8
8
|
import type { AsyncDatabase, Database } from "./Database.js";
|
|
9
9
|
import type { AsyncQuery, Query } from "./Query.js";
|
|
@@ -18,7 +18,7 @@ export declare type ItemValue<T extends Data = Data> = ItemData<T> | null;
|
|
|
18
18
|
export declare type ItemArray<T extends Data = Data> = ImmutableArray<ItemData<T>>;
|
|
19
19
|
/** A set of query constraints for item data. */
|
|
20
20
|
export declare type ItemConstraints<T extends Data = Data> = QueryConstraints<ItemData<T>>;
|
|
21
|
-
/** Reference to an item in a synchronous or asynchronous
|
|
21
|
+
/** Reference to an item in a synchronous or asynchronous database. */
|
|
22
22
|
declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<T>> implements Observable<ItemValue<T[K]>> {
|
|
23
23
|
abstract readonly db: Database<T> | AsyncDatabase<T>;
|
|
24
24
|
abstract readonly collection: K;
|
|
@@ -54,18 +54,18 @@ declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<
|
|
|
54
54
|
/** Set the complete data of this item. */
|
|
55
55
|
abstract set(data: T[K]): void | PromiseLike<void>;
|
|
56
56
|
/** Update this item. */
|
|
57
|
-
abstract update(updates: DataUpdate<T[K]> |
|
|
57
|
+
abstract update(updates: DataUpdate<T[K]> | Updates<T[K]>): void | PromiseLike<void>;
|
|
58
58
|
/** Delete this item. */
|
|
59
59
|
abstract delete(): void | PromiseLike<void>;
|
|
60
60
|
/** Get a set change for this item. */
|
|
61
61
|
getSet(data: T[K]): SetChange<T, K>;
|
|
62
62
|
/** Get an update change for this item. */
|
|
63
|
-
getUpdate(updates:
|
|
63
|
+
getUpdate(updates: Updates<T[K]>): UpdateChange<T, K>;
|
|
64
64
|
/** Get a delete change for this item. */
|
|
65
65
|
getDelete(): DeleteChange<T, K>;
|
|
66
66
|
toString(): `${K}/${string}`;
|
|
67
67
|
}
|
|
68
|
-
/** Reference to an item in a synchronous
|
|
68
|
+
/** Reference to an item in a synchronous database. */
|
|
69
69
|
export declare class Item<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseItem<T, K> {
|
|
70
70
|
readonly db: Database<T>;
|
|
71
71
|
readonly collection: K;
|
|
@@ -76,21 +76,21 @@ export declare class Item<T extends Datas = Datas, K extends Key<T> = Key<T>> ex
|
|
|
76
76
|
get value(): ItemValue<T[K]>;
|
|
77
77
|
get data(): ItemData<T[K]>;
|
|
78
78
|
set(data: T[K]): void;
|
|
79
|
-
update(updates:
|
|
79
|
+
update(updates: Updates<T[K]>): void;
|
|
80
80
|
delete(): void;
|
|
81
81
|
}
|
|
82
|
-
/** Reference to an item in an asynchronous
|
|
82
|
+
/** Reference to an item in an asynchronous database. */
|
|
83
83
|
export declare class AsyncItem<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseItem<T, K> {
|
|
84
84
|
readonly db: AsyncDatabase<T>;
|
|
85
85
|
readonly collection: K;
|
|
86
86
|
readonly id: string;
|
|
87
|
-
constructor(
|
|
87
|
+
constructor(db: AsyncDatabase<T>, collection: K, id: string);
|
|
88
88
|
get optional(): AsyncQuery<T, K>;
|
|
89
89
|
get exists(): Promise<boolean>;
|
|
90
90
|
get value(): Promise<ItemValue<T[K]>>;
|
|
91
91
|
get data(): Promise<ItemData<T[K]>>;
|
|
92
92
|
set(data: T[K]): Promise<void>;
|
|
93
|
-
update(updates:
|
|
93
|
+
update(updates: Updates<T[K]>): Promise<void>;
|
|
94
94
|
delete(): Promise<void>;
|
|
95
95
|
}
|
|
96
96
|
/** Get the ID from item data. */
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { getData } from "../util/data.js";
|
|
2
2
|
import { FilterConstraint } from "../constraint/FilterConstraint.js";
|
|
3
|
-
|
|
4
|
-
import { isTransformable } from "../util/transform.js";
|
|
5
|
-
/** Reference to an item in a synchronous or asynchronous provider. */
|
|
3
|
+
/** Reference to an item in a synchronous or asynchronous database. */
|
|
6
4
|
class BaseItem {
|
|
7
5
|
/**
|
|
8
6
|
* Subscribe to the result of this item (indefinitely).
|
|
@@ -12,26 +10,26 @@ class BaseItem {
|
|
|
12
10
|
* @return Function that ends the subscription.
|
|
13
11
|
*/
|
|
14
12
|
subscribe(next) {
|
|
15
|
-
return this.db.
|
|
13
|
+
return this.db.subscribe(this.collection, this.id, next);
|
|
16
14
|
}
|
|
17
15
|
/** Get a set change for this item. */
|
|
18
16
|
getSet(data) {
|
|
19
|
-
return
|
|
17
|
+
return this.db.getSet(this.collection, this.id, data);
|
|
20
18
|
}
|
|
21
19
|
/** Get an update change for this item. */
|
|
22
20
|
getUpdate(updates) {
|
|
23
|
-
return
|
|
21
|
+
return this.db.getUpdate(this.collection, this.id, updates);
|
|
24
22
|
}
|
|
25
23
|
/** Get a delete change for this item. */
|
|
26
24
|
getDelete() {
|
|
27
|
-
return
|
|
25
|
+
return this.db.getDelete(this.collection, this.id);
|
|
28
26
|
}
|
|
29
27
|
// Implement toString()
|
|
30
28
|
toString() {
|
|
31
29
|
return `${this.collection}/${this.id}`;
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
/** Reference to an item in a synchronous
|
|
32
|
+
/** Reference to an item in a synchronous database. */
|
|
35
33
|
export class Item extends BaseItem {
|
|
36
34
|
constructor(db, collection, id) {
|
|
37
35
|
super();
|
|
@@ -43,29 +41,29 @@ export class Item extends BaseItem {
|
|
|
43
41
|
return this.db.query(this.collection, new FilterConstraint("id", this.id), undefined, 1);
|
|
44
42
|
}
|
|
45
43
|
get exists() {
|
|
46
|
-
return !!this.db.
|
|
44
|
+
return !!this.db.get(this.collection, this.id);
|
|
47
45
|
}
|
|
48
46
|
get value() {
|
|
49
|
-
return this.db.
|
|
47
|
+
return this.db.get(this.collection, this.id);
|
|
50
48
|
}
|
|
51
49
|
get data() {
|
|
52
50
|
return getData(this.value);
|
|
53
51
|
}
|
|
54
52
|
set(data) {
|
|
55
|
-
return this.db.
|
|
53
|
+
return this.db.set(this.collection, this.id, data);
|
|
56
54
|
}
|
|
57
55
|
update(updates) {
|
|
58
|
-
return this.db.
|
|
56
|
+
return this.db.update(this.collection, this.id, updates);
|
|
59
57
|
}
|
|
60
58
|
delete() {
|
|
61
|
-
return this.db.
|
|
59
|
+
return this.db.delete(this.collection, this.id);
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
|
-
/** Reference to an item in an asynchronous
|
|
62
|
+
/** Reference to an item in an asynchronous database. */
|
|
65
63
|
export class AsyncItem extends BaseItem {
|
|
66
|
-
constructor(
|
|
64
|
+
constructor(db, collection, id) {
|
|
67
65
|
super();
|
|
68
|
-
this.db =
|
|
66
|
+
this.db = db;
|
|
69
67
|
this.collection = collection;
|
|
70
68
|
this.id = id;
|
|
71
69
|
}
|
|
@@ -73,22 +71,22 @@ export class AsyncItem extends BaseItem {
|
|
|
73
71
|
return this.db.query(this.collection, new FilterConstraint("id", this.id), undefined, 1);
|
|
74
72
|
}
|
|
75
73
|
get exists() {
|
|
76
|
-
return this.db.
|
|
74
|
+
return this.db.get(this.collection, this.id).then(Boolean);
|
|
77
75
|
}
|
|
78
76
|
get value() {
|
|
79
|
-
return this.db.
|
|
77
|
+
return this.db.get(this.collection, this.id);
|
|
80
78
|
}
|
|
81
79
|
get data() {
|
|
82
80
|
return this.value.then(getData);
|
|
83
81
|
}
|
|
84
82
|
set(data) {
|
|
85
|
-
return this.db.
|
|
83
|
+
return this.db.set(this.collection, this.id, data);
|
|
86
84
|
}
|
|
87
85
|
update(updates) {
|
|
88
|
-
return this.db.
|
|
86
|
+
return this.db.update(this.collection, this.id, updates);
|
|
89
87
|
}
|
|
90
88
|
delete() {
|
|
91
|
-
return this.db.
|
|
89
|
+
return this.db.delete(this.collection, this.id);
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
/** Get the ID from item data. */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Dispatch } from "../util/function.js";
|
|
2
2
|
import type { Key, Datas } from "../util/data.js";
|
|
3
|
+
import type { Updates } from "../update/DataUpdate.js";
|
|
3
4
|
import type { PartialObserver } from "../observe/Observer.js";
|
|
4
5
|
import type { Observable, Unsubscribe } from "../observe/Observable.js";
|
|
5
6
|
import type { FilterList } from "../constraint/FilterConstraint.js";
|
|
6
7
|
import type { SortList } from "../constraint/SortConstraint.js";
|
|
7
8
|
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
8
|
-
import { DataUpdate, PropUpdates } from "../update/DataUpdate.js";
|
|
9
9
|
import type { ItemArray, ItemValue, ItemData } from "./Item.js";
|
|
10
10
|
import type { AsyncDatabase, Database } from "./Database.js";
|
|
11
11
|
/** Reference to a set of items in a sync or async provider. */
|
|
@@ -68,7 +68,7 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key
|
|
|
68
68
|
* @param updates `Update` instance or set of updates to apply to every matching item.
|
|
69
69
|
* @return Nothing (possibly promised).
|
|
70
70
|
*/
|
|
71
|
-
abstract update(updates:
|
|
71
|
+
abstract update(updates: Updates<T[K]>): number | PromiseLike<number>;
|
|
72
72
|
/**
|
|
73
73
|
* Delete all matching items.
|
|
74
74
|
* @return Nothing (possibly promised).
|
|
@@ -80,7 +80,7 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key
|
|
|
80
80
|
export declare class Query<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseQuery<T, K> implements BaseQuery<T, K> {
|
|
81
81
|
readonly db: Database<T>;
|
|
82
82
|
readonly collection: K;
|
|
83
|
-
constructor(db: Database<T>, collection: K, filters?: FilterList<ItemData<T[K]
|
|
83
|
+
constructor(db: Database<T>, collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null);
|
|
84
84
|
get value(): ItemArray<T[K]>;
|
|
85
85
|
get count(): number;
|
|
86
86
|
get exists(): boolean;
|
|
@@ -89,14 +89,14 @@ export declare class Query<T extends Datas = Datas, K extends Key<T> = Key<T>> e
|
|
|
89
89
|
get lastValue(): ItemValue<T[K]>;
|
|
90
90
|
get lastData(): ItemData<T[K]>;
|
|
91
91
|
set(data: T[K]): number;
|
|
92
|
-
update(updates:
|
|
92
|
+
update(updates: Updates<T[K]>): number;
|
|
93
93
|
delete(): number;
|
|
94
94
|
}
|
|
95
95
|
/** Reference to a set of items in a provider. */
|
|
96
96
|
export declare class AsyncQuery<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseQuery<T, K> implements BaseQuery<T, K> {
|
|
97
97
|
readonly db: AsyncDatabase<T>;
|
|
98
98
|
readonly collection: K;
|
|
99
|
-
constructor(db: AsyncDatabase<T>, collection: K, filters?: FilterList<ItemData<T[K]
|
|
99
|
+
constructor(db: AsyncDatabase<T>, collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null);
|
|
100
100
|
get value(): Promise<ItemArray<T[K]>>;
|
|
101
101
|
get count(): Promise<number>;
|
|
102
102
|
get exists(): Promise<boolean>;
|
|
@@ -105,7 +105,7 @@ export declare class AsyncQuery<T extends Datas = Datas, K extends Key<T> = Key<
|
|
|
105
105
|
get lastValue(): Promise<ItemValue<T[K]>>;
|
|
106
106
|
get lastData(): Promise<ItemData<T[K]>>;
|
|
107
107
|
set(data: T[K]): Promise<number>;
|
|
108
|
-
update(updates:
|
|
108
|
+
update(updates: Updates<T[K]>): PromiseLike<number>;
|
|
109
109
|
delete(): PromiseLike<number>;
|
|
110
110
|
}
|
|
111
111
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getFirstItem, getLastItem, getOptionalFirstItem, getOptionalLastItem } from "../util/array.js";
|
|
2
2
|
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
3
3
|
import { countItems, hasItems } from "../util/iterate.js";
|
|
4
|
-
import { DataUpdate } from "../update/DataUpdate.js";
|
|
5
4
|
/** Reference to a set of items in a sync or async provider. */
|
|
6
5
|
class BaseQuery extends QueryConstraints {
|
|
7
6
|
/**
|
|
@@ -51,7 +50,7 @@ export class Query extends BaseQuery {
|
|
|
51
50
|
return this.db.provider.setQuery(this.collection, this, data);
|
|
52
51
|
}
|
|
53
52
|
update(updates) {
|
|
54
|
-
return this.db.provider.updateQuery(this.collection, this, updates
|
|
53
|
+
return this.db.provider.updateQuery(this.collection, this, updates);
|
|
55
54
|
}
|
|
56
55
|
delete() {
|
|
57
56
|
return this.db.provider.deleteQuery(this.collection, this);
|
|
@@ -89,7 +88,7 @@ export class AsyncQuery extends BaseQuery {
|
|
|
89
88
|
return this.db.provider.setQuery(this.collection, this, data);
|
|
90
89
|
}
|
|
91
90
|
update(updates) {
|
|
92
|
-
return this.db.provider.updateQuery(this.collection, this, updates
|
|
91
|
+
return this.db.provider.updateQuery(this.collection, this, updates);
|
|
93
92
|
}
|
|
94
93
|
delete() {
|
|
95
94
|
return this.db.provider.deleteQuery(this.collection, this);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -4,15 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
import { setPrototype } from "../util/class.js";
|
|
11
8
|
import { Feedback } from "./Feedback.js";
|
|
12
9
|
/** Specific type of `Feedback` to indicate an error (something went wrong). */
|
|
13
10
|
export class ErrorFeedback extends Feedback {
|
|
14
11
|
}
|
|
15
12
|
__decorate([
|
|
16
|
-
setPrototype("name", "ErrorFeedback")
|
|
17
|
-
__metadata("design:type", String)
|
|
13
|
+
setPrototype("name", "ErrorFeedback")
|
|
18
14
|
], ErrorFeedback.prototype, "name", void 0);
|
|
File without changes
|
|
@@ -4,9 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
import { isObject } from "../util/object.js";
|
|
11
8
|
import { getEntries } from "../util/entry.js";
|
|
12
9
|
import { setPrototype } from "../util/class.js";
|
|
@@ -28,8 +25,7 @@ export class Feedback {
|
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
__decorate([
|
|
31
|
-
setPrototype("name", "Feedback")
|
|
32
|
-
__metadata("design:type", String)
|
|
28
|
+
setPrototype("name", "Feedback")
|
|
33
29
|
], Feedback.prototype, "name", void 0);
|
|
34
30
|
/** Is an unknown value a `Feedback` object. */
|
|
35
31
|
export const isFeedback = (v) => isObject(v) && typeof v.name === "string" && v.name.endsWith("Feedback") && typeof v.message === "string";
|
|
File without changes
|
|
@@ -4,15 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
import { setPrototype } from "../util/class.js";
|
|
11
8
|
import { ErrorFeedback } from "./ErrorFeedback.js";
|
|
12
9
|
/** Specific type of `ErrorFeedback` returned from `validate()` when a value is invalid. */
|
|
13
10
|
export class InvalidFeedback extends ErrorFeedback {
|
|
14
11
|
}
|
|
15
12
|
__decorate([
|
|
16
|
-
setPrototype("name", "InvalidFeedback")
|
|
17
|
-
__metadata("design:type", String)
|
|
13
|
+
setPrototype("name", "InvalidFeedback")
|
|
18
14
|
], InvalidFeedback.prototype, "name", void 0);
|
|
File without changes
|
|
@@ -4,15 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
import { setPrototype } from "../util/class.js";
|
|
11
8
|
import { Feedback } from "./Feedback.js";
|
|
12
9
|
/** Specific type of `Feedback` to indicate success (something went right!). */
|
|
13
10
|
export class SuccessFeedback extends Feedback {
|
|
14
11
|
}
|
|
15
12
|
__decorate([
|
|
16
|
-
setPrototype("name", "SuccessFeedback")
|
|
17
|
-
__metadata("design:type", String)
|
|
13
|
+
setPrototype("name", "SuccessFeedback")
|
|
18
14
|
], SuccessFeedback.prototype, "name", void 0);
|
|
File without changes
|
|
@@ -4,15 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
import { setPrototype } from "../util/class.js";
|
|
11
8
|
import { Feedback } from "./Feedback.js";
|
|
12
9
|
/** Specific type of `Feedback` to indicate warning (something might go wrong soon). */
|
|
13
10
|
export class WarningFeedback extends Feedback {
|
|
14
11
|
}
|
|
15
12
|
__decorate([
|
|
16
|
-
setPrototype("name", "WarningFeedback")
|
|
17
|
-
__metadata("design:type", String)
|
|
13
|
+
setPrototype("name", "WarningFeedback")
|
|
18
14
|
], WarningFeedback.prototype, "name", void 0);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -4,7 +4,7 @@ import type { Unsubscribe } from "../../observe/Observable.js";
|
|
|
4
4
|
import type { AsyncProvider } from "../../provider/Provider.js";
|
|
5
5
|
import type { ItemArray, ItemValue, ItemConstraints } from "../../db/Item.js";
|
|
6
6
|
import { Observer, PartialObserver } from "../../observe/Observer.js";
|
|
7
|
-
import {
|
|
7
|
+
import { Updates } from "../../update/DataUpdate.js";
|
|
8
8
|
/**
|
|
9
9
|
* Firestore client database provider.
|
|
10
10
|
* - Works with the Firebase JS SDK.
|
|
@@ -18,11 +18,11 @@ export declare class FirestoreClientProvider implements AsyncProvider {
|
|
|
18
18
|
subscribeItem(collection: string, id: string, observer: PartialObserver<ItemValue>): Unsubscribe;
|
|
19
19
|
addItem(collection: string, data: Data): Promise<string>;
|
|
20
20
|
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
21
|
-
updateItem(collection: string, id: string,
|
|
21
|
+
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
22
22
|
deleteItem(collection: string, id: string): Promise<void>;
|
|
23
23
|
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
24
24
|
subscribeQuery(collection: string, constraints: ItemConstraints, observer: Observer<ItemArray>): Unsubscribe;
|
|
25
25
|
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
26
|
-
updateQuery(collection: string, constraints: ItemConstraints,
|
|
26
|
+
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
27
27
|
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
28
28
|
}
|
|
@@ -101,8 +101,8 @@ export class FirestoreClientProvider {
|
|
|
101
101
|
async setItem(collection, id, data) {
|
|
102
102
|
await setDoc(firestoreDocument(this._firestore, collection, id), data);
|
|
103
103
|
}
|
|
104
|
-
async updateItem(collection, id,
|
|
105
|
-
await updateDoc(firestoreDocument(this._firestore, collection, id), ..._getFieldValues(
|
|
104
|
+
async updateItem(collection, id, updates) {
|
|
105
|
+
await updateDoc(firestoreDocument(this._firestore, collection, id), ..._getFieldValues(Object.entries(updates)));
|
|
106
106
|
}
|
|
107
107
|
async deleteItem(collection, id) {
|
|
108
108
|
await deleteDoc(firestoreDocument(this._firestore, collection, id));
|
|
@@ -118,9 +118,9 @@ export class FirestoreClientProvider {
|
|
|
118
118
|
await Promise.all(snapshot.docs.map(s => setDoc(s.ref, data)));
|
|
119
119
|
return snapshot.size;
|
|
120
120
|
}
|
|
121
|
-
async updateQuery(collection, constraints,
|
|
121
|
+
async updateQuery(collection, constraints, updates) {
|
|
122
122
|
const snapshot = await getDocs(_getQuery(this._firestore, collection, constraints));
|
|
123
|
-
const fieldValues = Array.from(_getFieldValues(
|
|
123
|
+
const fieldValues = Array.from(_getFieldValues(Object.entries(updates)));
|
|
124
124
|
await Promise.all(snapshot.docs.map(s => updateDoc(s.ref, ...fieldValues)));
|
|
125
125
|
return snapshot.size;
|
|
126
126
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,7 @@ import type { Data } from "../../util/data.js";
|
|
|
3
3
|
import type { Unsubscribe } from "../../observe/Observable.js";
|
|
4
4
|
import type { AsyncProvider } from "../../provider/Provider.js";
|
|
5
5
|
import type { ItemArray, ItemValue, ItemConstraints } from "../../db/Item.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Updates } from "../../update/DataUpdate.js";
|
|
7
7
|
/**
|
|
8
8
|
* Firestore Lite client database provider.
|
|
9
9
|
* - Works with the Firebase JS SDK.
|
|
@@ -17,11 +17,11 @@ export declare class FirestoreLiteProvider implements AsyncProvider {
|
|
|
17
17
|
subscribeItem(): Unsubscribe;
|
|
18
18
|
addItem(collection: string, data: Data): Promise<string>;
|
|
19
19
|
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
20
|
-
updateItem(collection: string, id: string,
|
|
20
|
+
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
21
21
|
deleteItem(collection: string, id: string): Promise<void>;
|
|
22
22
|
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
23
23
|
subscribeQuery(): Unsubscribe;
|
|
24
24
|
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
25
|
-
updateQuery(collection: string, constraints: ItemConstraints,
|
|
25
|
+
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
26
26
|
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
27
27
|
}
|
|
@@ -101,8 +101,8 @@ export class FirestoreLiteProvider {
|
|
|
101
101
|
async setItem(collection, id, data) {
|
|
102
102
|
await setDoc(firestoreDocument(this._firestore, collection, id), data);
|
|
103
103
|
}
|
|
104
|
-
async updateItem(collection, id,
|
|
105
|
-
await updateDoc(firestoreDocument(this._firestore, collection, id), ..._getFieldValues(
|
|
104
|
+
async updateItem(collection, id, updates) {
|
|
105
|
+
await updateDoc(firestoreDocument(this._firestore, collection, id), ..._getFieldValues(Object.entries(updates)));
|
|
106
106
|
}
|
|
107
107
|
async deleteItem(collection, id) {
|
|
108
108
|
await deleteDoc(firestoreDocument(this._firestore, collection, id));
|
|
@@ -118,9 +118,9 @@ export class FirestoreLiteProvider {
|
|
|
118
118
|
await Promise.all(snapshot.docs.map(s => setDoc(s.ref, data)));
|
|
119
119
|
return snapshot.size;
|
|
120
120
|
}
|
|
121
|
-
async updateQuery(collection, constraints,
|
|
121
|
+
async updateQuery(collection, constraints, updates) {
|
|
122
122
|
const snapshot = await getDocs(_getQuery(this._firestore, collection, constraints));
|
|
123
|
-
const fieldValues = Array.from(_getFieldValues(
|
|
123
|
+
const fieldValues = Array.from(_getFieldValues(Object.entries(updates)));
|
|
124
124
|
await Promise.all(snapshot.docs.map(s => updateDoc(s.ref, ...fieldValues)));
|
|
125
125
|
return snapshot.size;
|
|
126
126
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,7 @@ import type { Unsubscribe } from "../../observe/Observable.js";
|
|
|
3
3
|
import type { AsyncProvider } from "../../provider/Provider.js";
|
|
4
4
|
import type { ItemArray, ItemValue, ItemConstraints } from "../../db/Item.js";
|
|
5
5
|
import { Observer } from "../../observe/Observer.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Updates } from "../../update/DataUpdate.js";
|
|
7
7
|
import { Data } from "../../util/data.js";
|
|
8
8
|
/**
|
|
9
9
|
* Firestore server database provider.
|
|
@@ -16,11 +16,11 @@ export declare class FirestoreServerProvider implements AsyncProvider {
|
|
|
16
16
|
subscribeItem(collection: string, id: string, observer: Observer<ItemValue>): Unsubscribe;
|
|
17
17
|
addItem(collection: string, data: Data): Promise<string>;
|
|
18
18
|
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
19
|
-
updateItem(collection: string, id: string,
|
|
19
|
+
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
20
20
|
deleteItem(collection: string, id: string): Promise<void>;
|
|
21
21
|
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
22
22
|
subscribeQuery(collection: string, constraints: ItemConstraints, observer: Observer<ItemArray>): Unsubscribe;
|
|
23
23
|
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
24
|
-
updateQuery(collection: string, constraints: ItemConstraints,
|
|
24
|
+
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
25
25
|
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
26
26
|
}
|
|
@@ -101,11 +101,11 @@ export class FirestoreServerProvider {
|
|
|
101
101
|
async setItem(collection, id, data) {
|
|
102
102
|
await this._firestore.collection(collection).doc(id).set(data);
|
|
103
103
|
}
|
|
104
|
-
async updateItem(collection, id,
|
|
104
|
+
async updateItem(collection, id, updates) {
|
|
105
105
|
await this._firestore
|
|
106
106
|
.collection(collection)
|
|
107
107
|
.doc(id)
|
|
108
|
-
.update(..._getFieldValues(
|
|
108
|
+
.update(..._getFieldValues(Object.entries(updates)));
|
|
109
109
|
}
|
|
110
110
|
async deleteItem(collection, id) {
|
|
111
111
|
await this._firestore.collection(collection).doc(id).delete();
|
|
@@ -119,8 +119,8 @@ export class FirestoreServerProvider {
|
|
|
119
119
|
async setQuery(collection, constraints, data) {
|
|
120
120
|
return await bulkWrite(this._firestore, collection, constraints, (w, s) => void w.set(s.ref, data));
|
|
121
121
|
}
|
|
122
|
-
async updateQuery(collection, constraints,
|
|
123
|
-
const fieldValues = _getFieldValues(
|
|
122
|
+
async updateQuery(collection, constraints, updates) {
|
|
123
|
+
const fieldValues = _getFieldValues(Object.entries(updates));
|
|
124
124
|
return await bulkWrite(this._firestore, collection, constraints, (w, s) => void w.update(s.ref, ...fieldValues));
|
|
125
125
|
}
|
|
126
126
|
async deleteQuery(collection, constraints) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|