@instantdb/core 0.22.86-experimental.split-store.20178922132.1 → 0.22.86-experimental.split-store.20183617880.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/Reactor.test.js +18 -11
- package/__tests__/src/{datalog.test.js → datalog.test.ts} +17 -5
- package/__tests__/src/{instaml.test.js → instaml.test.ts} +183 -119
- package/__tests__/src/instaql.bench.ts +34 -0
- package/__tests__/src/{instaql.test.js → instaql.test.ts} +342 -455
- package/__tests__/src/instaqlInference.test.js +13 -9
- package/__tests__/src/{store.test.js → store.test.ts} +188 -210
- package/dist/commonjs/Reactor.d.ts +4 -1
- package/dist/commonjs/Reactor.d.ts.map +1 -1
- package/dist/commonjs/Reactor.js +22 -12
- package/dist/commonjs/Reactor.js.map +1 -1
- package/dist/commonjs/instaml.d.ts +3 -3
- package/dist/commonjs/instaml.d.ts.map +1 -1
- package/dist/commonjs/instaml.js +2 -2
- package/dist/commonjs/instaml.js.map +1 -1
- package/dist/commonjs/instaql.d.ts +2 -2
- package/dist/commonjs/instaql.d.ts.map +1 -1
- package/dist/commonjs/instaql.js.map +1 -1
- package/dist/commonjs/store.d.ts +28 -9
- package/dist/commonjs/store.d.ts.map +1 -1
- package/dist/commonjs/store.js +13 -8
- package/dist/commonjs/store.js.map +1 -1
- package/dist/esm/Reactor.d.ts +4 -1
- package/dist/esm/Reactor.d.ts.map +1 -1
- package/dist/esm/Reactor.js +22 -12
- package/dist/esm/Reactor.js.map +1 -1
- package/dist/esm/instaml.d.ts +3 -3
- package/dist/esm/instaml.d.ts.map +1 -1
- package/dist/esm/instaml.js +3 -3
- package/dist/esm/instaml.js.map +1 -1
- package/dist/esm/instaql.d.ts +2 -2
- package/dist/esm/instaql.d.ts.map +1 -1
- package/dist/esm/instaql.js.map +1 -1
- package/dist/esm/store.d.ts +28 -9
- package/dist/esm/store.d.ts.map +1 -1
- package/dist/esm/store.js +11 -6
- package/dist/esm/store.js.map +1 -1
- package/dist/standalone/index.js +549 -533
- package/dist/standalone/index.umd.cjs +2 -2
- package/package.json +2 -2
- package/src/Reactor.js +44 -35
- package/src/instaml.ts +8 -7
- package/src/instaql.ts +2 -2
- package/src/store.ts +47 -19
- package/__tests__/src/instaql.bench.js +0 -29
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
|
-
import { createStore } from '../../src/store';
|
|
2
|
+
import { createStore, AttrsStoreClass } from '../../src/store';
|
|
3
3
|
import query from '../../src/instaql';
|
|
4
4
|
import { i, id } from '../../src';
|
|
5
5
|
import { createLinkIndex } from '../../src/utils/linkIndex';
|
|
@@ -221,19 +221,23 @@ test('one-to-one without inference', () => {
|
|
|
221
221
|
expect(result.data.profiles.at(0).user.at(0).id).toBe(ids.user1);
|
|
222
222
|
});
|
|
223
223
|
|
|
224
|
-
function indexAttrs(attrs) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
function indexAttrs(attrs, schema) {
|
|
225
|
+
const linkIndex = schema ? createLinkIndex(schema) : undefined;
|
|
226
|
+
return new AttrsStoreClass(
|
|
227
|
+
attrs.reduce((acc, attr) => {
|
|
228
|
+
acc[attr.id] = attr;
|
|
229
|
+
return acc;
|
|
230
|
+
}, {}),
|
|
231
|
+
linkIndex,
|
|
232
|
+
);
|
|
229
233
|
}
|
|
230
234
|
|
|
231
235
|
function queryData(config, attrs, triples, q) {
|
|
232
|
-
const
|
|
236
|
+
const attrsStore = indexAttrs(attrs, config.schema);
|
|
237
|
+
const store = createStore(attrsStore, triples);
|
|
233
238
|
store.cardinalityInference = config.cardinalityInference;
|
|
234
|
-
store.linkIndex = config.schema ? createLinkIndex(config.schema) : undefined;
|
|
235
239
|
|
|
236
|
-
const result = query({ store }, q);
|
|
240
|
+
const result = query({ store, attrsStore }, q);
|
|
237
241
|
|
|
238
242
|
return { result, store };
|
|
239
243
|
}
|