@roc-db/indexed-db 0.2.0-pre.53 → 0.2.0-pre.55
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/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __export(exports_functions, {
|
|
|
21
21
|
readEntity: () => readEntity,
|
|
22
22
|
pageMutations: () => pageMutations,
|
|
23
23
|
pageEntitiesByIndex: () => pageEntitiesByIndex,
|
|
24
|
+
pageEntities: () => pageEntities,
|
|
24
25
|
getChangeSetMutations: () => getChangeSetMutations,
|
|
25
26
|
findDebounceMutation: () => findDebounceMutation,
|
|
26
27
|
end: () => end,
|
|
@@ -278,6 +279,36 @@ var findDebounceMutation = async (request, engine, now, mutationName) => {
|
|
|
278
279
|
};
|
|
279
280
|
});
|
|
280
281
|
};
|
|
282
|
+
// src/functions/pageEntities.ts
|
|
283
|
+
var pageEntities = async (txn, args) => {
|
|
284
|
+
const { size, entities, childrenOf } = args;
|
|
285
|
+
const objectStore = txn.engineOpts.txn.objectStore("entities");
|
|
286
|
+
const idbRequest = objectStore.openCursor();
|
|
287
|
+
return new Promise((resolve, reject) => {
|
|
288
|
+
const results = [];
|
|
289
|
+
idbRequest.onsuccess = () => {
|
|
290
|
+
if (results.length >= size) {
|
|
291
|
+
resolve(results);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const cursor = idbRequest.result;
|
|
295
|
+
if (cursor) {
|
|
296
|
+
if (entities && entities !== "*" && !entities.includes(cursor.value.entity)) {
|
|
297
|
+
cursor.continue();
|
|
298
|
+
} else {
|
|
299
|
+
if (childrenOf && childrenOf.length > 0 && !childrenOf.some((childRef) => cursor.value.__.parentRefs.includes(childRef))) {
|
|
300
|
+
cursor.continue();
|
|
301
|
+
} else {
|
|
302
|
+
results.push(cursor.value);
|
|
303
|
+
cursor.continue();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
resolve(results);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
};
|
|
281
312
|
// src/functions/pageEntitiesByIndex.ts
|
|
282
313
|
var pageEntitiesByIndex = async (txn, entity, field, value) => {
|
|
283
314
|
const objectStore = txn.engineOpts.txn.objectStore("entities");
|
|
@@ -4,6 +4,7 @@ export { commit } from "./commit";
|
|
|
4
4
|
export { end } from "./end";
|
|
5
5
|
export { getChangeSetMutations } from "./getChangeSetMutations";
|
|
6
6
|
export { findDebounceMutation } from "./findDebounceMutation";
|
|
7
|
+
export { pageEntities } from "./pageEntities";
|
|
7
8
|
export { pageEntitiesByIndex } from "./pageEntitiesByIndex";
|
|
8
9
|
export { pageMutations } from "./pageMutations";
|
|
9
10
|
export { readEntity } from "./readEntity";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roc-db/indexed-db",
|
|
3
|
-
"version": "0.2.0-pre.
|
|
3
|
+
"version": "0.2.0-pre.55",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"dependencies": {},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"roc-db": "0.2.0-pre.
|
|
17
|
+
"roc-db": "0.2.0-pre.55",
|
|
18
18
|
"zod": "^3.0.0"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [],
|