@instantdb/core 0.22.88-experimental.drewh-entity-caching.20249092034.1 → 0.22.88-experimental.drewh-fix-explorer.20249092035.1
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/__tests__/src/instaql.bench.js +2 -80
- package/dist/commonjs/store.d.ts +1 -1
- package/dist/commonjs/store.d.ts.map +1 -1
- package/dist/commonjs/store.js +0 -5
- package/dist/commonjs/store.js.map +1 -1
- package/dist/esm/store.d.ts +1 -1
- package/dist/esm/store.d.ts.map +1 -1
- package/dist/esm/store.js +0 -5
- package/dist/esm/store.js.map +1 -1
- package/dist/standalone/index.js +722 -725
- package/dist/standalone/index.umd.cjs +3 -3
- package/package.json +2 -2
- package/src/store.ts +0 -6
- package/__tests__/src/instaqlCache.test.ts +0 -78
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantdb/core",
|
|
3
|
-
"version": "0.22.88-experimental.drewh-
|
|
3
|
+
"version": "0.22.88-experimental.drewh-fix-explorer.20249092035.1",
|
|
4
4
|
"description": "Instant's core local abstraction",
|
|
5
5
|
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/core",
|
|
6
6
|
"repository": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"mutative": "^1.0.10",
|
|
55
55
|
"uuid": "^11.1.0",
|
|
56
|
-
"@instantdb/version": "0.22.88-experimental.drewh-
|
|
56
|
+
"@instantdb/version": "0.22.88-experimental.drewh-fix-explorer.20249092035.1"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"test": "vitest",
|
package/src/store.ts
CHANGED
|
@@ -677,16 +677,11 @@ export function getTriples(store, [e, a, v]) {
|
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
679
|
|
|
680
|
-
const cache = {};
|
|
681
|
-
|
|
682
680
|
export function getAsObject(
|
|
683
681
|
store: Store,
|
|
684
682
|
attrs: Map<string, InstantDBAttr> | undefined,
|
|
685
683
|
e: string,
|
|
686
684
|
) {
|
|
687
|
-
if (cache[e]) {
|
|
688
|
-
return cache[e];
|
|
689
|
-
}
|
|
690
685
|
const obj = {};
|
|
691
686
|
|
|
692
687
|
if (!attrs) {
|
|
@@ -700,7 +695,6 @@ export function getAsObject(
|
|
|
700
695
|
obj[label] = triple[2];
|
|
701
696
|
}
|
|
702
697
|
}
|
|
703
|
-
cache[e] = obj;
|
|
704
698
|
|
|
705
699
|
return obj;
|
|
706
700
|
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { bench, describe } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import zenecaAttrs from './data/zeneca/attrs.json';
|
|
4
|
-
import * as instaml from '../../src/instaml';
|
|
5
|
-
import zenecaTriples from './data/zeneca/triples.json';
|
|
6
|
-
import { createStore, transact, getAllTriples } from '../../src/store';
|
|
7
|
-
import query from '../../src/instaql';
|
|
8
|
-
import { id, TransactionChunk, txInit } from '../../src';
|
|
9
|
-
|
|
10
|
-
function generateRandomString(length: number) {
|
|
11
|
-
const characters =
|
|
12
|
-
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
13
|
-
let result = '';
|
|
14
|
-
const charactersLength = characters.length;
|
|
15
|
-
for (let i = 0; i < length; i++) {
|
|
16
|
-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const zenecaIdToAttr = zenecaAttrs.reduce((res, x) => {
|
|
22
|
-
res[x.id] = x;
|
|
23
|
-
return res;
|
|
24
|
-
}, {});
|
|
25
|
-
|
|
26
|
-
const store = createStore(zenecaIdToAttr, zenecaTriples);
|
|
27
|
-
|
|
28
|
-
bench('big query', () => {
|
|
29
|
-
query(
|
|
30
|
-
{ store, aggregate: null, pageInfo: null },
|
|
31
|
-
{
|
|
32
|
-
users: {
|
|
33
|
-
bookshelves: {
|
|
34
|
-
books: {},
|
|
35
|
-
users: {
|
|
36
|
-
bookshelves: {},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe('entity caching', () => {
|
|
45
|
-
const emptyStore = createStore({}, []);
|
|
46
|
-
const tx = txInit();
|
|
47
|
-
|
|
48
|
-
const chunks: TransactionChunk<any, any>[] = [];
|
|
49
|
-
for (let i = 0; i < 10000; i++) {
|
|
50
|
-
chunks.push(
|
|
51
|
-
tx.hi[id()].create({
|
|
52
|
-
name: generateRandomString(10),
|
|
53
|
-
age: Math.floor(Math.random() * 100),
|
|
54
|
-
bio: generateRandomString(50),
|
|
55
|
-
field1: generateRandomString(10),
|
|
56
|
-
field2: generateRandomString(10),
|
|
57
|
-
field3: generateRandomString(10),
|
|
58
|
-
field4: generateRandomString(10),
|
|
59
|
-
field5: generateRandomString(10),
|
|
60
|
-
field6: generateRandomString(10),
|
|
61
|
-
field7: generateRandomString(10),
|
|
62
|
-
field8: generateRandomString(10),
|
|
63
|
-
field9: generateRandomString(10),
|
|
64
|
-
field10: generateRandomString(10),
|
|
65
|
-
}),
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const txSteps = instaml.transform({ attrs: store.attrs }, chunks);
|
|
70
|
-
|
|
71
|
-
const newStore = transact(emptyStore, txSteps);
|
|
72
|
-
|
|
73
|
-
const attrs = newStore.attrs;
|
|
74
|
-
const triples = getAllTriples(newStore);
|
|
75
|
-
console.log(triples.length);
|
|
76
|
-
|
|
77
|
-
const testingStore = createStore(attrs, triples);
|
|
78
|
-
});
|