@edgedev/firebase 1.9.6 → 1.9.8
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/edgeFirebase.ts +24 -10
- package/package.json +1 -1
- package/src/postinstall.sh +4 -4
package/edgeFirebase.ts
CHANGED
|
@@ -1303,8 +1303,8 @@ export const EdgeFirebase = class {
|
|
|
1303
1303
|
collectionPath: string,
|
|
1304
1304
|
docId: string
|
|
1305
1305
|
): Promise<actionResponse> => {
|
|
1306
|
-
console.log(collectionPath)
|
|
1307
|
-
console.log(docId)
|
|
1306
|
+
// console.log(collectionPath)
|
|
1307
|
+
// console.log(docId)
|
|
1308
1308
|
const canRead = await this.permissionCheck("read", collectionPath + '/' + docId);
|
|
1309
1309
|
this.data[collectionPath + '/' + docId] = {};
|
|
1310
1310
|
this.stopSnapshot(collectionPath + '/' + docId);
|
|
@@ -1347,8 +1347,9 @@ export const EdgeFirebase = class {
|
|
|
1347
1347
|
this.unsubscibe[collectionPath] = null;
|
|
1348
1348
|
if (canRead) {
|
|
1349
1349
|
const q = this.getQuery(collectionPath, queryList, orderList, max);
|
|
1350
|
-
|
|
1350
|
+
|
|
1351
1351
|
return new Promise<actionResponse>((resolve, reject) => {
|
|
1352
|
+
let firstRun = true;
|
|
1352
1353
|
const unsubscribe = onSnapshot(q, (querySnapshot) => {
|
|
1353
1354
|
const items = {};
|
|
1354
1355
|
querySnapshot.forEach((doc) => {
|
|
@@ -1358,13 +1359,25 @@ export const EdgeFirebase = class {
|
|
|
1358
1359
|
});
|
|
1359
1360
|
this.data[collectionPath] = items;
|
|
1360
1361
|
this.unsubscibe[collectionPath] = unsubscribe;
|
|
1361
|
-
|
|
1362
|
-
//
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1362
|
+
|
|
1363
|
+
// Only resolve or reject the Promise on first run of onSnapshot
|
|
1364
|
+
if(firstRun) {
|
|
1365
|
+
if(Object.keys(items).length > 0) { // resolve if items fetched
|
|
1366
|
+
firstRun = false;
|
|
1367
|
+
resolve(this.sendResponse({
|
|
1368
|
+
success: true,
|
|
1369
|
+
message: "",
|
|
1370
|
+
meta: {}
|
|
1371
|
+
}));
|
|
1372
|
+
} else { // reject if no items fetched
|
|
1373
|
+
firstRun = false;
|
|
1374
|
+
reject(this.sendResponse({
|
|
1375
|
+
success: false,
|
|
1376
|
+
message: `No data found in "${collectionPath}"`,
|
|
1377
|
+
meta: {}
|
|
1378
|
+
}));
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1368
1381
|
}, (error) => {
|
|
1369
1382
|
// Reject the Promise with the error response
|
|
1370
1383
|
reject(this.sendResponse({
|
|
@@ -1382,6 +1395,7 @@ export const EdgeFirebase = class {
|
|
|
1382
1395
|
});
|
|
1383
1396
|
}
|
|
1384
1397
|
};
|
|
1398
|
+
|
|
1385
1399
|
|
|
1386
1400
|
private usersSnapshotStarting = false;
|
|
1387
1401
|
|
package/package.json
CHANGED
package/src/postinstall.sh
CHANGED
|
@@ -24,10 +24,10 @@ awk '/\/\/ #EDGE FIREBASE RULES START/,/\/\/ #EDGE FIREBASE RULES END/' ./src/fi
|
|
|
24
24
|
|
|
25
25
|
if [ ! -f "$project_root/functions/index.js" ]; then
|
|
26
26
|
mkdir -p "$project_root/functions"
|
|
27
|
-
echo "const functions = require('firebase-functions')
|
|
28
|
-
echo "const admin = require('firebase-admin')
|
|
29
|
-
echo "admin.initializeApp()
|
|
30
|
-
echo "const db = admin.firestore()
|
|
27
|
+
echo "const functions = require('firebase-functions')" > "$project_root/functions/index.js";
|
|
28
|
+
echo "const admin = require('firebase-admin')" >> "$project_root/functions/index.js";
|
|
29
|
+
echo "admin.initializeApp()" >> "$project_root/functions/index.js";
|
|
30
|
+
echo "const db = admin.firestore()" >> "$project_root/functions/index.js";
|
|
31
31
|
fi
|
|
32
32
|
|
|
33
33
|
[ "$(tail -c1 $project_root/functions/index.js)" != "" ] && echo "" >> "$project_root/functions/index.js"
|