Socket
Book a DemoInstallSign in
Socket

@based/db

Package Overview
Dependencies
Maintainers
9
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@based/db - npm Package Compare versions

Comparing version

to
0.0.46

3

dist/src/client/query/debug.js

@@ -104,2 +104,5 @@ import picocolors from 'picocolors';

}
if (a[j + i * w] === 250) {
return picocolors.redBright(v);
}
return v;

@@ -106,0 +109,0 @@ })

2

dist/src/client/query/display.js

@@ -284,3 +284,3 @@ import picocolors from 'picocolors';

if (def.aggregate) {
str += inspectObject(q.toObject(), def, '', level + 1, i === max - 1, i === 0, false, depth);
str += inspectObject('toObject' in q ? q.toObject() : q, def, '', level + 1, i === max - 1, i === 0, false, depth);
return str;

@@ -287,0 +287,0 @@ }

@@ -21,3 +21,2 @@ import { QueryDefType } from '../types.js';

}
// main
if (def.include.main.len > 0) {

@@ -24,0 +23,0 @@ // if (def.target.)

@@ -6,3 +6,39 @@ import { ALIAS, ALIASES, BINARY, BOOLEAN, ENUM, INT16, INT32, INT8, NUMBER, STRING, TEXT, TIMESTAMP, UINT16, UINT32, UINT8, VECTOR, JSON, CARDINALITY, } from '@based/schema/def';

import { inverseLangMap } from '@based/schema';
import { READ_EDGE, READ_ID, READ_REFERENCE, READ_REFERENCES, } from '../types.js';
import { READ_EDGE, READ_ID, READ_REFERENCE, READ_REFERENCES, READ_AGGREGATION, } from '../types.js';
const readAggregate = (q, result, offset, len) => {
const results = {};
if (q.aggregate.groupBy) {
let i = offset;
while (i < len) {
let key = '';
if (result[i] == 0) {
if (q.aggregate.groupBy.default) {
key = q.aggregate.groupBy.default;
}
else {
key = `$undefined`;
}
}
else {
key = DECODER.decode(result.subarray(i, i + 2));
}
i += 2;
const resultKey = (results[key] = {});
for (const aggregatesArray of q.aggregate.aggregates.values()) {
for (const agg of aggregatesArray) {
setByPath(resultKey, agg.propDef.path, readUint32(result, agg.resultPos + i));
}
}
i += q.aggregate.totalResultsPos;
}
}
else {
for (const aggregatesArray of q.aggregate.aggregates.values()) {
for (const agg of aggregatesArray) {
setByPath(results, agg.propDef.path, readUint32(result, agg.resultPos + offset));
}
}
}
return results;
};
const addField = (p, value, item, defaultOnly = false, lang = 0) => {

@@ -179,3 +215,15 @@ let i = p.__isEdge === true ? 1 : 0;

}
if (index === READ_EDGE) {
if (index === READ_AGGREGATION) {
// also for edges at some point!
let field = result[i];
i++;
const size = readUint32(result, i);
i += 4;
const ref = q.references.get(field);
addField(
// @ts-ignore
ref.target.propDef, readAggregate(ref, result, i, i + size), item);
i += size;
}
else if (index === READ_EDGE) {
let prop = result[i];

@@ -374,40 +422,3 @@ if (prop === READ_REFERENCE) {

if (q.aggregate) {
const results = {};
// range for numbers
if (q.aggregate.groupBy) {
// key size = 2 for now... not perfect...
let i = 0;
while (i < result.byteLength - 4) {
// if group = 0
// add extra thing for the keys maybe?
let key = '';
if (result[i] == 0) {
if (q.aggregate.groupBy.default) {
key = q.aggregate.groupBy.default;
}
else {
key = `$undefined`;
}
}
else {
key = DECODER.decode(result.subarray(i, i + 2));
}
i += 2;
const resultKey = (results[key] = {});
for (const aggregatesArray of q.aggregate.aggregates.values()) {
for (const agg of aggregatesArray) {
setByPath(resultKey, agg.propDef.path, readUint32(result, agg.resultPos + i));
}
}
i += q.aggregate.totalResultsPos;
}
}
else {
for (const aggregatesArray of q.aggregate.aggregates.values()) {
for (const agg of aggregatesArray) {
setByPath(results, agg.propDef.path, readUint32(result, agg.resultPos));
}
}
}
return results;
return readAggregate(q, result, 0, result.byteLength - 4);
}

@@ -414,0 +425,0 @@ const len = readUint32(result, offset);

@@ -42,26 +42,54 @@ import { createSortBuffer } from './sort.js';

const filterSize = def.filter.size || 0;
const buf = new Uint8Array(16 + filterSize + aggregateSize);
buf[0] = isRootCountOnly(def, filterSize)
? QueryType.aggregatesCountType
: QueryType.aggregates;
buf[1] = def.schema.idUint8[0];
buf[2] = def.schema.idUint8[1];
buf[3] = def.range.offset;
buf[4] = def.range.offset >>> 8;
buf[5] = def.range.offset >>> 16;
buf[6] = def.range.offset >>> 24;
buf[7] = def.range.limit;
buf[8] = def.range.limit >>> 8;
buf[9] = def.range.limit >>> 16;
buf[10] = def.range.limit >>> 24;
buf[11] = filterSize;
buf[12] = filterSize >>> 8;
if (filterSize) {
buf.set(filterToBuffer(def.filter), 13);
if (def.type === QueryDefType.References) {
const buf = new Uint8Array(13 + filterSize + aggregateSize);
const sz = 10 + filterSize + aggregateSize;
buf[0] = 251 /* includeOp.REFERENCES_AGGREGATION */;
buf[1] = sz;
buf[2] = sz >>> 8;
// ---
buf[3] = filterSize;
buf[4] = filterSize >>> 8;
buf[5] = def.range.offset;
buf[6] = def.range.offset >>> 8;
buf[7] = def.range.offset >>> 16;
buf[8] = def.range.offset >>> 24;
if (filterSize) {
buf.set(filterToBuffer(def.filter), 9);
}
// required to get typeEntry and fieldSchema
buf[9 + filterSize] = def.schema.idUint8[0]; // typeId
buf[9 + 1 + filterSize] = def.schema.idUint8[1]; // typeId
buf[9 + 2 + filterSize] = def.target.propDef.prop; // refField
const aggregateBuffer = aggregateToBuffer(def.aggregate);
buf.set(aggregateBuffer, 9 + 3 + filterSize);
// buf[12 + filterSize] = aggregateSize
// buf[12 + 1 + filterSize] = aggregateSize >>> 8
result.push(buf);
}
const aggregateBuffer = aggregateToBuffer(def.aggregate);
buf[14 + filterSize] = aggregateSize;
buf[15 + filterSize] = aggregateSize >>> 8;
buf.set(aggregateBuffer, 16 + filterSize);
result.push(buf);
else {
const buf = new Uint8Array(16 + filterSize + aggregateSize);
buf[0] = isRootCountOnly(def, filterSize)
? QueryType.aggregatesCountType
: QueryType.aggregates;
buf[1] = def.schema.idUint8[0];
buf[2] = def.schema.idUint8[1];
buf[3] = def.range.offset;
buf[4] = def.range.offset >>> 8;
buf[5] = def.range.offset >>> 16;
buf[6] = def.range.offset >>> 24;
buf[7] = def.range.limit;
buf[8] = def.range.limit >>> 8;
buf[9] = def.range.limit >>> 16;
buf[10] = def.range.limit >>> 24;
buf[11] = filterSize;
buf[12] = filterSize >>> 8;
if (filterSize) {
buf.set(filterToBuffer(def.filter), 13);
}
const aggregateBuffer = aggregateToBuffer(def.aggregate);
buf[14 + filterSize] = aggregateSize;
buf[15 + filterSize] = aggregateSize >>> 8;
buf.set(aggregateBuffer, 16 + filterSize);
result.push(buf);
}
// ignore this for now...

@@ -210,3 +238,3 @@ // result.push(...include)

const sz = size + 7 + modsSize + 8;
meta[0] = 254;
meta[0] = 254 /* includeOp.REFERENCES */;
meta[1] = sz;

@@ -240,3 +268,3 @@ meta[2] = sz >>> 8;

const sz = size + 3;
meta[0] = 255;
meta[0] = 255 /* includeOp.REFERENCE */;
meta[1] = sz;

@@ -252,3 +280,3 @@ meta[2] = sz >>> 8;

const metaEdgeBuffer = new Uint8Array(3);
metaEdgeBuffer[0] = 252;
metaEdgeBuffer[0] = 252 /* includeOp.EDGE */;
metaEdgeBuffer[1] = edgesSize;

@@ -255,0 +283,0 @@ metaEdgeBuffer[2] = edgesSize >>> 8;

@@ -143,1 +143,8 @@ import { LangCode } from '@based/schema';

export declare const READ_REFERENCE = 254;
export declare const READ_AGGREGATION = 250;
export declare const enum includeOp {
REFERENCES_AGGREGATION = 251,
EDGE = 252,
REFERENCES = 254,
REFERENCE = 255
}

@@ -34,2 +34,3 @@ export var QueryType;

export const READ_REFERENCE = 254;
export const READ_AGGREGATION = 250;
//# sourceMappingURL=types.js.map
{
"name": "@based/db",
"version": "0.0.45",
"version": "0.0.46",
"license": "MIT",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet