@based/db 0.2.22 → 0.2.23

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
@@ -1,3 +1,4 @@
1
+ import { CARDINALITY_RAW } from '@based/schema/def';
1
2
  import { deleteProp } from './delete.js';
2
3
  import { writeU32, writeU8, writeU8Array } from '../uint.js';
3
4
  import { validate } from '../validate.js';
@@ -29,7 +30,17 @@ export const writeCardinality = (ctx, def, val) => {
29
30
  return;
30
31
  }
31
32
  if (val instanceof Uint8Array && val.byteLength !== 8) {
32
- writeBinary(ctx, def, val, true);
33
+ if (ctx.unsafe) {
34
+ const size = val.byteLength;
35
+ reserve(ctx, PROP_CURSOR_SIZE + size + 5);
36
+ writePropCursor(ctx, def, CARDINALITY_RAW);
37
+ writeU8(ctx, ctx.operation);
38
+ writeU32(ctx, size);
39
+ writeU8Array(ctx, val);
40
+ }
41
+ else {
42
+ writeBinary(ctx, def, val, true);
43
+ }
33
44
  return;
34
45
  }
35
46
  if (!Array.isArray(val)) {
@@ -1,4 +1,4 @@
1
- import { MICRO_BUFFER, STRING, TEXT, JSON, BINARY } from '@based/schema/def';
1
+ import { MICRO_BUFFER, STRING, TEXT, JSON, BINARY, CARDINALITY, CARDINALITY_RAW, } from '@based/schema/def';
2
2
  import { QueryDefType, } from '../types.js';
3
3
  import { walkDefs } from './walk.js';
4
4
  import { langCodesMap } from '@based/schema';
@@ -69,7 +69,11 @@ export const includeToBuffer = (db, def) => {
69
69
  }
70
70
  if (propSize) {
71
71
  for (const [prop, propDef] of def.include.props.entries()) {
72
- const typeIndex = propDef.opts?.raw ? BINARY : propDef.def.typeIndex;
72
+ const typeIndex = propDef.opts?.raw
73
+ ? propDef.def.typeIndex === CARDINALITY
74
+ ? CARDINALITY_RAW
75
+ : BINARY
76
+ : propDef.def.typeIndex;
73
77
  if (propDef.opts?.meta) {
74
78
  if (propDef.opts.codes) {
75
79
  if (propDef.opts.codes.has(0)) {
@@ -1,11 +1,15 @@
1
1
  // import type { IncludeOpts, QueryDef, Target } from '@based/db'
2
2
  import { inverseLangMap, langCodesMap } from '@based/schema';
3
- import { COLVEC, ENUM, TEXT, VECTOR, BINARY, CARDINALITY, } from '@based/schema/def';
3
+ import { COLVEC, ENUM, TEXT, VECTOR, BINARY, CARDINALITY, CARDINALITY_RAW, } from '@based/schema/def';
4
4
  import { ReaderMeta, ReaderSchemaEnum, } from '@based/protocol/db-read';
5
5
  const createReaderPropDef = (p, locales, opts) => {
6
6
  const readerPropDef = {
7
7
  path: p.__isEdge ? p.path.slice(1) : p.path,
8
- typeIndex: opts?.raw ? BINARY : p.typeIndex,
8
+ typeIndex: opts?.raw
9
+ ? p.typeIndex == CARDINALITY
10
+ ? CARDINALITY_RAW
11
+ : BINARY
12
+ : p.typeIndex,
9
13
  readBy: 0,
10
14
  };
11
15
  if (opts?.meta) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/db",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "scripts": {
@@ -43,9 +43,9 @@
43
43
  ],
44
44
  "dependencies": {
45
45
  "@based/hash": "1.1.5",
46
- "@based/schema": "5.1.9",
46
+ "@based/schema": "5.1.10",
47
47
  "@based/utils": "1.2.5",
48
- "@based/protocol": "0.1.10",
48
+ "@based/protocol": "0.1.11",
49
49
  "exit-hook": "^4.0.0"
50
50
  },
51
51
  "optionalDependencies": {