@based/db 0.0.68 → 0.0.69
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/README.md +6 -1
- package/dist/lib/darwin_aarch64/include/selva/fields.h +0 -9
- package/dist/lib/darwin_aarch64/include/selva_error.h +4 -1
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/selva/fields.h +0 -9
- package/dist/lib/linux_aarch64/include/selva_error.h +4 -1
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/selva/fields.h +0 -9
- package/dist/lib/linux_x86_64/include/selva_error.h +4 -1
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/modify/alias.js +4 -0
- package/dist/src/client/modify/binary.d.ts +1 -1
- package/dist/src/client/modify/binary.js +22 -7
- package/dist/src/client/modify/create.js +87 -39
- package/dist/src/client/modify/fixed.d.ts +3 -3
- package/dist/src/client/modify/fixed.js +80 -20
- package/dist/src/client/modify/json.js +7 -0
- package/dist/src/client/modify/modify.js +3 -3
- package/dist/src/client/modify/references/edge.js +3 -3
- package/dist/src/client/modify/string.d.ts +1 -1
- package/dist/src/client/modify/string.js +17 -7
- package/dist/src/client/modify/text.d.ts +1 -1
- package/dist/src/client/modify/text.js +27 -15
- package/dist/src/client/modify/types.d.ts +2 -1
- package/dist/src/client/modify/types.js +6 -0
- package/dist/src/client/modify/update.js +1 -1
- package/dist/src/client/query/display.js +1 -1
- package/dist/src/client/query/filter/createFixedFilterBuffer.js +3 -0
- package/dist/src/client/query/filter/createReferenceFilter.js +3 -0
- package/dist/src/client/query/filter/createVariableFilterBuffer.js +21 -19
- package/dist/src/client/query/read/read.js +9 -10
- package/dist/src/native.d.ts +1 -0
- package/dist/src/native.js +3 -0
- package/dist/src/server/IoWorker.d.ts +16 -0
- package/dist/src/server/IoWorker.js +32 -3
- package/dist/src/server/QueryWorker.js +2 -2
- package/dist/src/server/blocks.d.ts +3 -1
- package/dist/src/server/blocks.js +31 -7
- package/dist/src/server/index.d.ts +1 -1
- package/dist/src/server/index.js +8 -11
- package/dist/src/server/migrate/index.js +5 -5
- package/dist/src/server/save.d.ts +7 -1
- package/dist/src/server/save.js +107 -50
- package/dist/src/server/schema.d.ts +1 -1
- package/dist/src/server/schema.js +6 -2
- package/dist/src/server/start.js +11 -5
- package/dist/src/server/tree.d.ts +11 -0
- package/dist/src/server/tree.js +0 -1
- package/dist/src/server/workers/DbWorker.d.ts +3 -2
- package/dist/src/server/workers/DbWorker.js +2 -1
- package/dist/src/server/workers/io_worker.js +22 -17
- package/dist/src/server/workers/io_worker_types.d.ts +9 -1
- package/dist/src/server/workers/worker.js +11 -3
- package/dist/src/types.d.ts +1 -0
- package/dist/src/types.js +1 -0
- package/dist/src/utils.js +1 -1
- package/package.json +3 -2
- package/dist/lib/darwin_aarch64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
package/README.md
CHANGED
|
@@ -619,6 +619,11 @@ await clientDb.setSchema({
|
|
|
619
619
|
/* ... new or modified schema ... */
|
|
620
620
|
},
|
|
621
621
|
})
|
|
622
|
+
```
|
|
622
623
|
|
|
623
624
|
// Server processes and notifies clients.
|
|
624
|
-
|
|
625
|
+
|
|
626
|
+
### Aggregations
|
|
627
|
+
|
|
628
|
+
BasedDb support aggregate functions such as `sum('prop1','prop2')`, `count()`, etc and operations such as `groupBY('prop')`.
|
|
629
|
+
See the specific doc [Aggregations](./README_Aggregate.md) for a detailed guide on its usage and features.
|
|
@@ -115,15 +115,6 @@ void selva_fields_ensure_ref_meta(
|
|
|
115
115
|
const struct EdgeFieldConstraint *efc)
|
|
116
116
|
__attribute__((nonnull));
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* Set field value.
|
|
120
|
-
*/
|
|
121
|
-
SELVA_EXPORT
|
|
122
|
-
int selva_fields_set(
|
|
123
|
-
struct SelvaNode *node,
|
|
124
|
-
const struct SelvaFieldSchema *fs,
|
|
125
|
-
const void *value, size_t len) __attribute__((deprecated));
|
|
126
|
-
|
|
127
118
|
SELVA_EXPORT
|
|
128
119
|
int selva_fields_get_mutable_string(
|
|
129
120
|
struct SelvaNode *node,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2025 SAULX
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
#pragma once
|
|
6
6
|
|
|
7
|
+
#include "selva/_export.h"
|
|
8
|
+
|
|
7
9
|
/*
|
|
8
10
|
* Error codes.
|
|
9
11
|
*/
|
|
@@ -134,4 +136,5 @@
|
|
|
134
136
|
* Selva error code to string.
|
|
135
137
|
* Implemented in libutil.
|
|
136
138
|
*/
|
|
139
|
+
SELVA_EXPORT
|
|
137
140
|
const char *selva_strerror(int err);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -115,15 +115,6 @@ void selva_fields_ensure_ref_meta(
|
|
|
115
115
|
const struct EdgeFieldConstraint *efc)
|
|
116
116
|
__attribute__((nonnull));
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* Set field value.
|
|
120
|
-
*/
|
|
121
|
-
SELVA_EXPORT
|
|
122
|
-
int selva_fields_set(
|
|
123
|
-
struct SelvaNode *node,
|
|
124
|
-
const struct SelvaFieldSchema *fs,
|
|
125
|
-
const void *value, size_t len) __attribute__((deprecated));
|
|
126
|
-
|
|
127
118
|
SELVA_EXPORT
|
|
128
119
|
int selva_fields_get_mutable_string(
|
|
129
120
|
struct SelvaNode *node,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2025 SAULX
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
#pragma once
|
|
6
6
|
|
|
7
|
+
#include "selva/_export.h"
|
|
8
|
+
|
|
7
9
|
/*
|
|
8
10
|
* Error codes.
|
|
9
11
|
*/
|
|
@@ -134,4 +136,5 @@
|
|
|
134
136
|
* Selva error code to string.
|
|
135
137
|
* Implemented in libutil.
|
|
136
138
|
*/
|
|
139
|
+
SELVA_EXPORT
|
|
137
140
|
const char *selva_strerror(int err);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -115,15 +115,6 @@ void selva_fields_ensure_ref_meta(
|
|
|
115
115
|
const struct EdgeFieldConstraint *efc)
|
|
116
116
|
__attribute__((nonnull));
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* Set field value.
|
|
120
|
-
*/
|
|
121
|
-
SELVA_EXPORT
|
|
122
|
-
int selva_fields_set(
|
|
123
|
-
struct SelvaNode *node,
|
|
124
|
-
const struct SelvaFieldSchema *fs,
|
|
125
|
-
const void *value, size_t len) __attribute__((deprecated));
|
|
126
|
-
|
|
127
118
|
SELVA_EXPORT
|
|
128
119
|
int selva_fields_get_mutable_string(
|
|
129
120
|
struct SelvaNode *node,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2025 SAULX
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
#pragma once
|
|
6
6
|
|
|
7
|
+
#include "selva/_export.h"
|
|
8
|
+
|
|
7
9
|
/*
|
|
8
10
|
* Error codes.
|
|
9
11
|
*/
|
|
@@ -134,4 +136,5 @@
|
|
|
134
136
|
* Selva error code to string.
|
|
135
137
|
* Implemented in libutil.
|
|
136
138
|
*/
|
|
139
|
+
SELVA_EXPORT
|
|
137
140
|
const char *selva_strerror(int err);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -26,6 +26,10 @@ export function writeAlias(value, ctx, def, t, parentId, modifyOp) {
|
|
|
26
26
|
if (modifyOp === CREATE) {
|
|
27
27
|
def.seperateSort.bufferTmp[t.prop] = 2;
|
|
28
28
|
ctx.hasSortField++;
|
|
29
|
+
if (def.hasSeperateDefaults) {
|
|
30
|
+
def.seperateDefaults.bufferTmp[t.prop] = 1;
|
|
31
|
+
ctx.hasDefaults++;
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
setCursor(ctx, def, t.prop, t.typeIndex, parentId, modifyOp);
|
|
31
35
|
ctx.buf[ctx.len++] = modifyOp;
|
|
@@ -3,4 +3,4 @@ import { PropDef, SchemaTypeDef } from '@based/schema/def';
|
|
|
3
3
|
import { ModifyOp, ModifyErr } from './types.js';
|
|
4
4
|
export declare function getBuffer(value: any): Uint8Array | undefined;
|
|
5
5
|
export declare function writeBinaryRaw(value: Uint8Array, ctx: ModifyCtx): void;
|
|
6
|
-
export declare function writeBinary(value: any, ctx: ModifyCtx, schema: SchemaTypeDef, t: PropDef,
|
|
6
|
+
export declare function writeBinary(value: any, ctx: ModifyCtx, schema: SchemaTypeDef, t: PropDef, id: number, modifyOp: ModifyOp): ModifyErr;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ENCODER } from '@saulx/utils';
|
|
2
|
-
import { UPDATE, RANGE_ERR, DELETE, } from './types.js';
|
|
2
|
+
import { UPDATE, RANGE_ERR, DELETE, CREATE, MOD_OPS_TO_STRING, } from './types.js';
|
|
3
3
|
import { ModifyError } from './ModifyRes.js';
|
|
4
4
|
import { setCursor } from './setCursor.js';
|
|
5
5
|
import native from '../../native.js';
|
|
@@ -32,15 +32,24 @@ export function writeBinaryRaw(value, ctx) {
|
|
|
32
32
|
ctx.buf[ctx.len++] = crc >>>= 8;
|
|
33
33
|
ctx.buf[ctx.len++] = crc >>>= 8;
|
|
34
34
|
}
|
|
35
|
-
export function writeBinary(value, ctx, schema, t,
|
|
35
|
+
export function writeBinary(value, ctx, schema, t, id, modifyOp) {
|
|
36
36
|
let size;
|
|
37
37
|
if (value === null) {
|
|
38
38
|
size = 0;
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (t.transform) {
|
|
42
|
+
// validation happens before
|
|
43
|
+
if (!value || !t.validation(value, t)) {
|
|
44
|
+
return new ModifyError(t, value);
|
|
45
|
+
}
|
|
46
|
+
value = getBuffer(t.transform(MOD_OPS_TO_STRING[modifyOp], value));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
value = getBuffer(value);
|
|
50
|
+
if (!value || !t.validation(value, t)) {
|
|
51
|
+
return new ModifyError(t, value);
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
size = value.byteLength + 6;
|
|
46
55
|
}
|
|
@@ -49,7 +58,7 @@ export function writeBinary(value, ctx, schema, t, parentId, modifyOp) {
|
|
|
49
58
|
if (ctx.len + 11 /* SIZE.DEFAULT_CURSOR */ + 1 > ctx.max) {
|
|
50
59
|
return RANGE_ERR;
|
|
51
60
|
}
|
|
52
|
-
setCursor(ctx, schema, t.prop, t.typeIndex,
|
|
61
|
+
setCursor(ctx, schema, t.prop, t.typeIndex, id, modifyOp);
|
|
53
62
|
ctx.buf[ctx.len++] = DELETE;
|
|
54
63
|
}
|
|
55
64
|
}
|
|
@@ -57,7 +66,13 @@ export function writeBinary(value, ctx, schema, t, parentId, modifyOp) {
|
|
|
57
66
|
if (ctx.len + 11 /* SIZE.DEFAULT_CURSOR */ + 5 + size > ctx.max) {
|
|
58
67
|
return RANGE_ERR;
|
|
59
68
|
}
|
|
60
|
-
|
|
69
|
+
if (modifyOp === CREATE) {
|
|
70
|
+
if (schema.hasSeperateDefaults) {
|
|
71
|
+
schema.seperateDefaults.bufferTmp[t.prop] = 1;
|
|
72
|
+
ctx.hasDefaults++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
setCursor(ctx, schema, t.prop, t.typeIndex, id, modifyOp);
|
|
61
76
|
ctx.buf[ctx.len++] = modifyOp;
|
|
62
77
|
writeBinaryRaw(value, ctx);
|
|
63
78
|
}
|
|
@@ -1,69 +1,127 @@
|
|
|
1
|
-
import { MICRO_BUFFER } from '@based/schema/def';
|
|
1
|
+
import { BINARY, MICRO_BUFFER, STRING, JSON, TEXT, ALIAS, } from '@based/schema/def';
|
|
2
|
+
import { inverseLangMap } from '@based/schema';
|
|
2
3
|
import { startDrain, flushBuffer } from '../flushModify.js';
|
|
3
4
|
import { setCursor } from './setCursor.js';
|
|
4
5
|
import { modify } from './modify.js';
|
|
5
6
|
import { ModifyState } from './ModifyRes.js';
|
|
6
7
|
import { CREATE, RANGE_ERR, ADD_EMPTY_SORT, ADD_EMPTY_SORT_TEXT, } from './types.js';
|
|
7
8
|
import { writeFixedValue } from './fixed.js';
|
|
8
|
-
|
|
9
|
+
import { writeBinary } from './binary.js';
|
|
10
|
+
import { writeString } from './string.js';
|
|
11
|
+
import { writeText } from './text.js';
|
|
12
|
+
import { writeJson } from './json.js';
|
|
13
|
+
import { writeAlias } from './alias.js';
|
|
14
|
+
const appendCreate = (ctx, schema, obj, res, unsafe) => {
|
|
9
15
|
const len = ctx.len;
|
|
10
|
-
let err = modify(ctx, res, obj,
|
|
16
|
+
let err = modify(ctx, res, obj, schema, CREATE, schema.tree, true, unsafe);
|
|
11
17
|
if (err) {
|
|
12
18
|
return err;
|
|
13
19
|
}
|
|
14
|
-
if (ctx.len === len ||
|
|
20
|
+
if (ctx.len === len || schema.mainLen === 0) {
|
|
15
21
|
if (ctx.len + 11 /* SIZE.DEFAULT_CURSOR */ > ctx.max) {
|
|
16
22
|
return RANGE_ERR;
|
|
17
23
|
}
|
|
18
|
-
setCursor(ctx,
|
|
24
|
+
setCursor(ctx, schema, 0, MICRO_BUFFER, res.tmpId, CREATE);
|
|
19
25
|
}
|
|
20
|
-
if (
|
|
26
|
+
if (schema.createTs) {
|
|
21
27
|
const createTs = Date.now();
|
|
22
|
-
for (const prop of
|
|
28
|
+
for (const prop of schema.createTs) {
|
|
23
29
|
if (ctx.lastMain === -1) {
|
|
24
|
-
let mainLenU32 =
|
|
25
|
-
setCursor(ctx,
|
|
30
|
+
let mainLenU32 = schema.mainLen;
|
|
31
|
+
setCursor(ctx, schema, prop.prop, MICRO_BUFFER, res.tmpId, CREATE);
|
|
26
32
|
ctx.buf[ctx.len++] = CREATE;
|
|
27
33
|
ctx.buf[ctx.len++] = mainLenU32;
|
|
28
34
|
ctx.buf[ctx.len++] = mainLenU32 >>>= 8;
|
|
29
35
|
ctx.buf[ctx.len++] = mainLenU32 >>>= 8;
|
|
30
36
|
ctx.buf[ctx.len++] = mainLenU32 >>>= 8;
|
|
31
37
|
ctx.lastMain = ctx.len;
|
|
32
|
-
ctx.buf.set(
|
|
33
|
-
ctx.len +=
|
|
38
|
+
ctx.buf.set(schema.mainEmpty, ctx.len);
|
|
39
|
+
ctx.len += schema.mainLen;
|
|
34
40
|
}
|
|
35
|
-
err = writeFixedValue(ctx, createTs, prop, ctx.lastMain + prop.start);
|
|
41
|
+
err = writeFixedValue(ctx, createTs, prop, ctx.lastMain + prop.start, CREATE);
|
|
36
42
|
if (err) {
|
|
37
43
|
return err;
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
|
-
else if (ctx.lastMain === -1 && !
|
|
47
|
+
else if (ctx.lastMain === -1 && !schema.mainEmptyAllZeroes) {
|
|
42
48
|
// this is there to handle different defaults
|
|
43
49
|
if (ctx.lastMain === -1) {
|
|
44
|
-
let mainLenU32 =
|
|
45
|
-
setCursor(ctx,
|
|
50
|
+
let mainLenU32 = schema.mainLen;
|
|
51
|
+
setCursor(ctx, schema, 0, MICRO_BUFFER, res.tmpId, CREATE);
|
|
46
52
|
ctx.buf[ctx.len++] = CREATE;
|
|
47
53
|
ctx.buf[ctx.len++] = mainLenU32;
|
|
48
54
|
ctx.buf[ctx.len++] = mainLenU32 >>>= 8;
|
|
49
55
|
ctx.buf[ctx.len++] = mainLenU32 >>>= 8;
|
|
50
56
|
ctx.buf[ctx.len++] = mainLenU32 >>>= 8;
|
|
51
57
|
ctx.lastMain = ctx.len;
|
|
52
|
-
ctx.buf.set(
|
|
53
|
-
ctx.len +=
|
|
58
|
+
ctx.buf.set(schema.mainEmpty, ctx.len);
|
|
59
|
+
ctx.len += schema.mainLen;
|
|
54
60
|
}
|
|
55
61
|
// add text & string here
|
|
56
62
|
}
|
|
57
|
-
if (
|
|
58
|
-
|
|
63
|
+
if (schema.hasSeperateDefaults) {
|
|
64
|
+
const buf = schema.seperateDefaults.bufferTmp;
|
|
65
|
+
// if ctx.hasDefault === -1 means it needs defaults
|
|
66
|
+
if (ctx.hasDefaults !== schema.seperateDefaults.props.size - 1) {
|
|
67
|
+
const id = res.tmpId;
|
|
68
|
+
for (const propDef of schema.seperateDefaults.props.values()) {
|
|
69
|
+
const prop = propDef.prop;
|
|
70
|
+
const type = propDef.typeIndex;
|
|
71
|
+
if (schema.seperateDefaults.bufferTmp[prop] === 0) {
|
|
72
|
+
if (type === BINARY) {
|
|
73
|
+
writeBinary(propDef.default, ctx, schema, propDef, id, CREATE);
|
|
74
|
+
}
|
|
75
|
+
else if (type === STRING) {
|
|
76
|
+
writeString(0, propDef.default, ctx, schema, propDef, id, CREATE);
|
|
77
|
+
}
|
|
78
|
+
else if (type === TEXT) {
|
|
79
|
+
writeText(propDef.default, ctx, schema, propDef, res, id, CREATE);
|
|
80
|
+
}
|
|
81
|
+
else if (type === JSON) {
|
|
82
|
+
writeJson(propDef.default, ctx, schema, propDef, id, CREATE);
|
|
83
|
+
}
|
|
84
|
+
else if (type === ALIAS) {
|
|
85
|
+
writeAlias(propDef.default, ctx, schema, propDef, id, CREATE);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (type === TEXT) {
|
|
89
|
+
const buf = schema.seperateTextSort.bufferTmp;
|
|
90
|
+
const amount = schema.localeSize + 1;
|
|
91
|
+
const len = amount * schema.seperateTextSort.props.length;
|
|
92
|
+
for (const { prop } of schema.seperateTextSort.props) {
|
|
93
|
+
const index = prop * amount;
|
|
94
|
+
if (buf[index] !== 0) {
|
|
95
|
+
for (let i = index + 1; i < len + index; i++) {
|
|
96
|
+
const lang = buf[i];
|
|
97
|
+
if (lang !== 0) {
|
|
98
|
+
const val = propDef.default[inverseLangMap.get(lang)];
|
|
99
|
+
if (val !== undefined) {
|
|
100
|
+
writeString(lang, val, ctx, schema, propDef, res.tmpId, CREATE);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (ctx.hasDefaults !== -1) {
|
|
110
|
+
buf.fill(0);
|
|
111
|
+
}
|
|
112
|
+
ctx.hasDefaults = -1;
|
|
113
|
+
}
|
|
114
|
+
if (schema.hasSeperateSort) {
|
|
115
|
+
// just do it here!
|
|
116
|
+
if (ctx.hasSortField !== schema.seperateSort.size - 1) {
|
|
59
117
|
if (ctx.len + 3 > ctx.max) {
|
|
60
118
|
return RANGE_ERR;
|
|
61
119
|
}
|
|
62
120
|
ctx.buf[ctx.len++] = ADD_EMPTY_SORT;
|
|
63
121
|
let sizepos = ctx.len;
|
|
64
122
|
ctx.len += 2;
|
|
65
|
-
for (const { prop } of
|
|
66
|
-
if (
|
|
123
|
+
for (const { prop } of schema.seperateSort.props) {
|
|
124
|
+
if (schema.seperateSort.bufferTmp[prop] === 0) {
|
|
67
125
|
if (ctx.len + 1 > ctx.max) {
|
|
68
126
|
return RANGE_ERR;
|
|
69
127
|
}
|
|
@@ -75,33 +133,23 @@ const appendCreate = (ctx, def, obj, res, unsafe) => {
|
|
|
75
133
|
ctx.buf[sizepos] = size >>>= 8;
|
|
76
134
|
}
|
|
77
135
|
if (ctx.hasSortField !== -1) {
|
|
78
|
-
|
|
136
|
+
schema.seperateSort.bufferTmp.set(schema.seperateSort.buffer, 0);
|
|
79
137
|
}
|
|
80
138
|
// add test for this
|
|
81
139
|
ctx.hasSortField = -1;
|
|
82
140
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// //
|
|
87
|
-
// }
|
|
88
|
-
// if (ctx.hasDefaults !== -1) {
|
|
89
|
-
// buf.set(def.seperateTextSort.buffer, 0)
|
|
90
|
-
// }
|
|
91
|
-
// ctx.hasDefaults = -1
|
|
92
|
-
// }
|
|
93
|
-
if (def.hasSeperateTextSort) {
|
|
94
|
-
const buf = def.seperateTextSort.bufferTmp;
|
|
95
|
-
if (ctx.hasSortText !== def.seperateTextSort.size - 1) {
|
|
141
|
+
if (schema.hasSeperateTextSort) {
|
|
142
|
+
const buf = schema.seperateTextSort.bufferTmp;
|
|
143
|
+
if (ctx.hasSortText !== schema.seperateTextSort.size - 1) {
|
|
96
144
|
if (ctx.len + 3 > ctx.max) {
|
|
97
145
|
return RANGE_ERR;
|
|
98
146
|
}
|
|
99
147
|
ctx.buf[ctx.len++] = ADD_EMPTY_SORT_TEXT;
|
|
100
148
|
let sizepos = ctx.len;
|
|
101
149
|
ctx.len += 2;
|
|
102
|
-
const amount =
|
|
103
|
-
const len = amount *
|
|
104
|
-
for (const { prop } of
|
|
150
|
+
const amount = schema.localeSize + 1;
|
|
151
|
+
const len = amount * schema.seperateTextSort.props.length;
|
|
152
|
+
for (const { prop } of schema.seperateTextSort.props) {
|
|
105
153
|
const index = prop * amount;
|
|
106
154
|
if (buf[index] !== 0) {
|
|
107
155
|
ctx.buf[ctx.len++] = prop;
|
|
@@ -120,7 +168,7 @@ const appendCreate = (ctx, def, obj, res, unsafe) => {
|
|
|
120
168
|
// [size][size] [prop][len][lang][lang]
|
|
121
169
|
}
|
|
122
170
|
if (ctx.hasSortText !== -1) {
|
|
123
|
-
buf.set(
|
|
171
|
+
buf.set(schema.seperateTextSort.buffer, 0);
|
|
124
172
|
}
|
|
125
173
|
ctx.hasSortText = -1;
|
|
126
174
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
2
|
import { PropDef, PropDefEdge } from '@based/schema/def';
|
|
3
|
-
import { ModifyErr } from './types.js';
|
|
4
|
-
export declare const writeFixedValue: (ctx: ModifyCtx,
|
|
5
|
-
export declare const appendFixedValue: (ctx: ModifyCtx, val: any, def: PropDef | PropDefEdge) => ModifyErr;
|
|
3
|
+
import { ModifyErr, ModifyOp } from './types.js';
|
|
4
|
+
export declare const writeFixedValue: (ctx: ModifyCtx, value: any, def: PropDef | PropDefEdge, pos: number, mod: ModifyOp) => ModifyErr;
|
|
5
|
+
export declare const appendFixedValue: (ctx: ModifyCtx, val: any, def: PropDef | PropDefEdge, mod: ModifyOp) => ModifyErr;
|