@based/db 0.0.6 → 0.0.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.
Binary file
Binary file
@@ -134,10 +134,13 @@ export const convertFilter = (field, operator, value) => {
134
134
  }
135
135
  else {
136
136
  if (operator == 'like') {
137
- if (value.normalize) {
137
+ if (value == null) {
138
+ throw new Error('Value is required');
139
+ }
140
+ if (value?.normalize) {
138
141
  value = normalizeNeedle(value);
139
142
  }
140
- else {
143
+ else if (Array.isArray(value) && value[0]?.normalize) {
141
144
  value = value.map(normalizeNeedle);
142
145
  }
143
146
  }
@@ -50,7 +50,6 @@ export const runSubscription = (subscription) => {
50
50
  else {
51
51
  subscription.res = new BasedQueryResponse(q.id, q.def, buf, performance.now() - d);
52
52
  }
53
- console.log('RUN ', subscription.subs.size);
54
53
  subscription.subs.forEach((fn) => {
55
54
  fn(subscription.res, err);
56
55
  });
@@ -280,7 +280,7 @@ export class DbServer {
280
280
  if (strictSchema.props) {
281
281
  // insert a root node
282
282
  const data = [2, 1, 0, 0, 0, 9, 1, 0, 0, 0, 7, 1, 0, 1];
283
- const blockKey = makeCsmtKey(1, 0);
283
+ const blockKey = makeCsmtKey(1, 1);
284
284
  const buf = Buffer.alloc(data.length + 2 + 8 + 4);
285
285
  // add content
286
286
  buf.set(data);
@@ -1,10 +1,14 @@
1
1
  import { BasedDb } from '../../index.js';
2
- import { join } from 'path';
2
+ import { dirname, join } from 'path';
3
3
  import { tmpdir } from 'os';
4
4
  import { Worker, MessageChannel } from 'node:worker_threads';
5
5
  import native from '../../native.js';
6
6
  import './worker.js';
7
7
  import { foreachDirtyBlock } from '../tree.js';
8
+ import { fileURLToPath } from 'url';
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = dirname(__filename);
11
+ const workerPath = join(__dirname, 'worker.js');
8
12
  let migrationCnt = 0;
9
13
  const parseTransform = (transform) => {
10
14
  const res = {};
@@ -45,7 +49,7 @@ export const migrate = async (fromDbServer, toSchema, transform) => {
45
49
  const toAddress = native.intFromExternal(toCtx);
46
50
  const transformFns = parseTransform(transform);
47
51
  atomics[0] = 1;
48
- const worker = new Worker('./dist/src/server/migrate/worker.js', {
52
+ const worker = new Worker(workerPath, {
49
53
  workerData: {
50
54
  from: fromAddress,
51
55
  to: toAddress,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/db",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",