@roc-db/in-memory 0.2.0-pre.52 → 0.2.0-pre.54
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
|
@@ -24,6 +24,7 @@ __export(exports_functions, {
|
|
|
24
24
|
readEntity: () => readEntity,
|
|
25
25
|
pageMutations: () => pageMutations,
|
|
26
26
|
pageEntitiesByIndex: () => pageEntitiesByIndex,
|
|
27
|
+
pageEntities: () => pageEntities,
|
|
27
28
|
getChangeSetMutations: () => getChangeSetMutations,
|
|
28
29
|
findDebounceMutation: () => findDebounceMutation,
|
|
29
30
|
commit: () => commit,
|
|
@@ -131,6 +132,20 @@ var commit = (txn, mutation, {
|
|
|
131
132
|
if (ref.startsWith("Mutation/")) {
|
|
132
133
|
txn.engineOpts.mutations.delete(ref);
|
|
133
134
|
} else {
|
|
135
|
+
const existingDocument = txn.engineOpts.entities.get(ref);
|
|
136
|
+
if (existingDocument.__.unique?.length) {
|
|
137
|
+
existingDocument.__.unique.forEach(([key, value]) => {
|
|
138
|
+
const uniqueKey = `${existingDocument.entity}:${key}:${JSON.stringify(value)}`;
|
|
139
|
+
txn.engineOpts.entitiesUnique.delete(uniqueKey);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (existingDocument.__.index?.length) {
|
|
143
|
+
existingDocument.__.index.forEach(([key, value]) => {
|
|
144
|
+
const indexKey = `${existingDocument.entity}:${key}:${JSON.stringify(value)}`;
|
|
145
|
+
const arr = txn.engineOpts.entitiesIndex.get(indexKey) ?? [];
|
|
146
|
+
txn.engineOpts.entitiesIndex.set(indexKey, arr.filter((ref2) => ref2 !== existingDocument.ref));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
134
149
|
txn.engineOpts.entities.delete(ref);
|
|
135
150
|
}
|
|
136
151
|
}
|
|
@@ -159,6 +174,27 @@ var getChangeSetMutations = (txn, changeSetRef) => {
|
|
|
159
174
|
});
|
|
160
175
|
return res;
|
|
161
176
|
};
|
|
177
|
+
// src/functions/pageEntities.ts
|
|
178
|
+
var pageEntities = (txn, args) => {
|
|
179
|
+
const { size, entities, childrenOf } = args;
|
|
180
|
+
const result = [];
|
|
181
|
+
for (const [, doc] of txn.engineOpts.entities) {
|
|
182
|
+
if (size && result.length >= size) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
if (entities && entities !== "*" && !entities.includes(doc.entity)) {
|
|
186
|
+
continue;
|
|
187
|
+
} else {
|
|
188
|
+
if (childrenOf && childrenOf.length > 0) {
|
|
189
|
+
if (!childrenOf.some((childRef) => doc.__.parentRefs.includes(childRef))) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
result.push(doc);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return result;
|
|
197
|
+
};
|
|
162
198
|
// src/functions/pageEntitiesByIndex.ts
|
|
163
199
|
var pageEntitiesByIndex = (txn, entity, field, value) => {
|
|
164
200
|
const { entitiesIndex } = txn.engineOpts;
|
|
@@ -2,6 +2,7 @@ export { batchReadEntities } from "./batchReadEntities";
|
|
|
2
2
|
export { commit } from "./commit";
|
|
3
3
|
export { findDebounceMutation } from "./findDebounceMutation";
|
|
4
4
|
export { getChangeSetMutations } from "./getChangeSetMutations";
|
|
5
|
+
export { pageEntities } from "./pageEntities";
|
|
5
6
|
export { pageEntitiesByIndex } from "./pageEntitiesByIndex";
|
|
6
7
|
export { pageMutations } from "./pageMutations";
|
|
7
8
|
export { readEntity } from "./readEntity";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pageEntities: (txn: any, args: any) => any[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roc-db/in-memory",
|
|
3
|
-
"version": "0.2.0-pre.
|
|
3
|
+
"version": "0.2.0-pre.54",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"roc-db": "0.2.0-pre.
|
|
16
|
+
"roc-db": "0.2.0-pre.54",
|
|
17
17
|
"zod": "^3.0.0"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [],
|