@pbvision/firestore-orm 0.0.16 → 0.0.18
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/package.json +2 -2
- package/scripts/firebase.json +0 -3
- package/scripts/start-local-db.sh +0 -1
- package/src/models.js +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbvision/firestore-orm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Firestore ORM Library",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@google-cloud/firestore": "^7.1.0",
|
|
43
|
-
"@pbvision/schema": "^0.2.
|
|
43
|
+
"@pbvision/schema": "^0.2.29",
|
|
44
44
|
"deep-object-diff": "^1.1.7",
|
|
45
45
|
"fast-deep-equal": "^3.1.3",
|
|
46
46
|
"fast-json-stable-stringify": "^2.1.0",
|
package/scripts/firebase.json
CHANGED
package/src/models.js
CHANGED
|
@@ -61,6 +61,27 @@ export class Model {
|
|
|
61
61
|
Object.seal(this)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/** Returns a query object for querying this model. */
|
|
65
|
+
static makeQuery () {
|
|
66
|
+
return Key.firestoreDB.collection(this.collectionName)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Runs a query object returned by this model's makeQuery() function.
|
|
71
|
+
* @returns {Array<Model>} returns an array of instances of this class that
|
|
72
|
+
* matched the query
|
|
73
|
+
*/
|
|
74
|
+
static async runQuery (query) {
|
|
75
|
+
const results = await query.get()
|
|
76
|
+
const ret = []
|
|
77
|
+
results.forEach(raw => {
|
|
78
|
+
const vals = raw.data()
|
|
79
|
+
vals.__id = raw.id
|
|
80
|
+
ret.push(new this(false, vals))
|
|
81
|
+
})
|
|
82
|
+
return ret
|
|
83
|
+
}
|
|
84
|
+
|
|
64
85
|
static async register (registrar) {
|
|
65
86
|
this.__doOneTimeModelPrep()
|
|
66
87
|
await registrar.registerModel(this)
|