serialized-query
Advanced tools
Comparing version 0.10.3 to 0.10.5
import { IDictionary } from "common-types"; | ||
import { Query } from "@firebase/database-types"; | ||
import { DB } from "abstracted-admin"; | ||
export declare type DataSnapshot = import("@firebase/database-types").DataSnapshot; | ||
@@ -35,3 +36,3 @@ export interface ISimplifiedDBAdaptor { | ||
static path<T extends object = IDictionary>(path?: string): SerializedQuery<T>; | ||
db: ISimplifiedDBAdaptor; | ||
db: DB; | ||
protected _path: string; | ||
@@ -70,3 +71,3 @@ protected _limitToFirst: number; | ||
*/ | ||
setDB(db: ISimplifiedDBAdaptor): this; | ||
setDB(db: DB): this; | ||
/** | ||
@@ -76,7 +77,7 @@ * Generates a Firebase `Query` from the _state_ in | ||
*/ | ||
deserialize(db?: ISimplifiedDBAdaptor): Query; | ||
deserialize(db: DB): Query; | ||
/** allows you to add a handler/transformer for snapshots with the results of the execute() method */ | ||
handleSnapshot(fn: (snap: DataSnapshot) => any): this; | ||
/** execute the query as a one time fetch */ | ||
execute(): Promise<any>; | ||
execute(db?: DB): Promise<any>; | ||
/** allows a shorthand notation for simple serialized queries */ | ||
@@ -83,0 +84,0 @@ where<V>(operation: IComparisonOperator, value: V, key?: keyof T & string): this; |
@@ -140,3 +140,5 @@ "use strict"; | ||
if (this._equalTo) { | ||
q = q.equalTo(this.identity.equalTo, this.identity.equalToKey); | ||
q = this.identity.equalToKey | ||
? q.equalTo(this.identity.equalTo, this.identity.equalToKey) | ||
: q.equalTo(this.identity.equalTo); | ||
} | ||
@@ -151,4 +153,8 @@ return q; | ||
/** execute the query as a one time fetch */ | ||
async execute() { | ||
const snap = await this.deserialize().once("value"); | ||
async execute(db) { | ||
const database = db || this.db; | ||
if (!database) { | ||
throw new Error(`Attempt to call serialized-query's execute() method but no database was passed in (or set with setDB)`); | ||
} | ||
const snap = await this.deserialize(database).once("value"); | ||
return this._handleSnapshot ? this._handleSnapshot(snap) : snap; | ||
@@ -179,19 +185,19 @@ } | ||
startAt: this._startAt, | ||
startAtKey: this._startAtKey | ||
? this._startAtKey | ||
: this._orderBy === "orderByChild" | ||
? this._orderKey | ||
: undefined, | ||
startAtKey: this._startAtKey, | ||
// ? this._startAtKey | ||
// : this._orderBy === "orderByChild" | ||
// ? this._orderKey | ||
// : undefined, | ||
endAt: this._endAt, | ||
endAtKey: this._endAtKey | ||
? this._endAtKey | ||
: this._orderBy === "orderByChild" | ||
? this._orderKey | ||
: undefined, | ||
endAtKey: this._endAtKey, | ||
// ? this._endAtKey | ||
// : this._orderBy === "orderByChild" | ||
// ? this._orderKey | ||
// : undefined, | ||
equalTo: this._equalTo, | ||
equalToKey: this._equalToKey | ||
? this._equalToKey | ||
: this._orderBy === "orderByChild" | ||
? this._orderKey | ||
: undefined, | ||
equalToKey: this._equalToKey, | ||
// ? this._equalToKey | ||
// : this._orderBy === "orderByChild" | ||
// ? this._orderKey | ||
// : undefined, | ||
path: this._path | ||
@@ -198,0 +204,0 @@ }; |
import { IDictionary } from "common-types"; | ||
import { Query } from "@firebase/database-types"; | ||
import { DB } from "abstracted-admin"; | ||
export declare type DataSnapshot = import("@firebase/database-types").DataSnapshot; | ||
@@ -35,3 +36,3 @@ export interface ISimplifiedDBAdaptor { | ||
static path<T extends object = IDictionary>(path?: string): SerializedQuery<T>; | ||
db: ISimplifiedDBAdaptor; | ||
db: DB; | ||
protected _path: string; | ||
@@ -70,3 +71,3 @@ protected _limitToFirst: number; | ||
*/ | ||
setDB(db: ISimplifiedDBAdaptor): this; | ||
setDB(db: DB): this; | ||
/** | ||
@@ -76,7 +77,7 @@ * Generates a Firebase `Query` from the _state_ in | ||
*/ | ||
deserialize(db?: ISimplifiedDBAdaptor): Query; | ||
deserialize(db: DB): Query; | ||
/** allows you to add a handler/transformer for snapshots with the results of the execute() method */ | ||
handleSnapshot(fn: (snap: DataSnapshot) => any): this; | ||
/** execute the query as a one time fetch */ | ||
execute(): Promise<any>; | ||
execute(db?: DB): Promise<any>; | ||
/** allows a shorthand notation for simple serialized queries */ | ||
@@ -83,0 +84,0 @@ where<V>(operation: IComparisonOperator, value: V, key?: keyof T & string): this; |
@@ -146,3 +146,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (this._equalTo) { | ||
q = q.equalTo(this.identity.equalTo, this.identity.equalToKey); | ||
q = this.identity.equalToKey | ||
? q.equalTo(this.identity.equalTo, this.identity.equalToKey) | ||
: q.equalTo(this.identity.equalTo); | ||
} | ||
@@ -157,5 +159,9 @@ return q; | ||
/** execute the query as a one time fetch */ | ||
execute() { | ||
execute(db) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const snap = yield this.deserialize().once("value"); | ||
const database = db || this.db; | ||
if (!database) { | ||
throw new Error(`Attempt to call serialized-query's execute() method but no database was passed in (or set with setDB)`); | ||
} | ||
const snap = yield this.deserialize(database).once("value"); | ||
return this._handleSnapshot ? this._handleSnapshot(snap) : snap; | ||
@@ -187,19 +193,19 @@ }); | ||
startAt: this._startAt, | ||
startAtKey: this._startAtKey | ||
? this._startAtKey | ||
: this._orderBy === "orderByChild" | ||
? this._orderKey | ||
: undefined, | ||
startAtKey: this._startAtKey, | ||
// ? this._startAtKey | ||
// : this._orderBy === "orderByChild" | ||
// ? this._orderKey | ||
// : undefined, | ||
endAt: this._endAt, | ||
endAtKey: this._endAtKey | ||
? this._endAtKey | ||
: this._orderBy === "orderByChild" | ||
? this._orderKey | ||
: undefined, | ||
endAtKey: this._endAtKey, | ||
// ? this._endAtKey | ||
// : this._orderBy === "orderByChild" | ||
// ? this._orderKey | ||
// : undefined, | ||
equalTo: this._equalTo, | ||
equalToKey: this._equalToKey | ||
? this._equalToKey | ||
: this._orderBy === "orderByChild" | ||
? this._orderKey | ||
: undefined, | ||
equalToKey: this._equalToKey, | ||
// ? this._equalToKey | ||
// : this._orderBy === "orderByChild" | ||
// ? this._orderKey | ||
// : undefined, | ||
path: this._path | ||
@@ -206,0 +212,0 @@ }; |
{ | ||
"name": "serialized-query", | ||
"version": "0.10.3", | ||
"version": "0.10.5", | ||
"description": "A simple Typescript class to serialize Firebase queries", | ||
@@ -28,4 +28,4 @@ "license": "MIT", | ||
"@firebase/database-types": "^0.4.10", | ||
"@firebase/util": "^0.2.36", | ||
"common-types": "^1.12.15" | ||
"@firebase/util": "^0.2.38", | ||
"common-types": "^1.12.18" | ||
}, | ||
@@ -44,3 +44,3 @@ "devDependencies": { | ||
"firemock": "^0.36.0", | ||
"firemodel": "^0.36.0", | ||
"firemodel": "^0.36.6", | ||
"js-yaml": "^3.13.1", | ||
@@ -56,3 +56,4 @@ "lodash": "^4.17.11", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^3.7.3" | ||
"typed-conversions": "^0.10.1", | ||
"typescript": "^3.7.5" | ||
}, | ||
@@ -59,0 +60,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36365
645
24
Updated@firebase/util@^0.2.38
Updatedcommon-types@^1.12.18