@trust0/ridb-core 1.2.0 → 1.3.0
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/package.json +1 -1
- package/pkg/ridb_core.d.ts +292 -266
- package/pkg/ridb_core.js +340 -218
- package/pkg/ridb_core_bg.wasm +0 -0
package/pkg/ridb_core.d.ts
CHANGED
|
@@ -63,18 +63,27 @@ export enum OpType {
|
|
|
63
63
|
COUNT = 4,
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export type Operators = {
|
|
66
|
+
export type Operators<T> = {
|
|
67
67
|
$gte?: number,
|
|
68
68
|
$gt?: number
|
|
69
69
|
$lt?: number,
|
|
70
|
-
$lte?: number
|
|
70
|
+
$lte?: number,
|
|
71
|
+
$eq?: T,
|
|
72
|
+
$ne?: T
|
|
71
73
|
};
|
|
74
|
+
|
|
72
75
|
export type InOperator<T> = { $in?: T[] };
|
|
73
|
-
export type
|
|
76
|
+
export type NInOperator<T> = { $nin?: T[] };
|
|
77
|
+
|
|
78
|
+
export type OperatorOrType<T> = T extends number ?
|
|
79
|
+
T | Operators<T> | InOperator<T> | NInOperator<T> :
|
|
80
|
+
T | InOperator<T> | NInOperator<T>;
|
|
81
|
+
|
|
74
82
|
export type LogicalOperators<T extends SchemaType> = {
|
|
75
83
|
$and?: Partial<QueryType<T>>[];
|
|
76
84
|
$or?: Partial<QueryType<T>>[];
|
|
77
85
|
};
|
|
86
|
+
|
|
78
87
|
export type QueryType<T extends SchemaType> = Partial<{
|
|
79
88
|
[K in keyof T['properties']]: OperatorOrType<
|
|
80
89
|
ExtractType<
|
|
@@ -82,51 +91,113 @@ export type QueryType<T extends SchemaType> = Partial<{
|
|
|
82
91
|
>
|
|
83
92
|
>
|
|
84
93
|
}> & LogicalOperators<T> | LogicalOperators<T>[];
|
|
94
|
+
|
|
85
95
|
export class Query<T extends SchemaType> {
|
|
86
96
|
constructor(query: QueryType<T>, schema:Schema<T>);
|
|
87
97
|
readonly query: QueryType<T>;
|
|
88
98
|
}
|
|
89
|
-
//test
|
|
90
99
|
|
|
91
100
|
|
|
92
101
|
|
|
93
|
-
export type
|
|
94
|
-
[name:string]:
|
|
102
|
+
export type InternalsRecord = {
|
|
103
|
+
[name: string]: BaseStorage<SchemaTypeRecord>
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
|
|
107
|
+
*
|
|
108
|
+
* @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* type StringType = ExtractType<'string'>; // StringType is string
|
|
112
|
+
* type NumberType = ExtractType<'number'>; // NumberType is number
|
|
113
|
+
* type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
|
|
114
|
+
* type ObjectType = ExtractType<'object'>; // ObjectType is object
|
|
115
|
+
* type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
|
|
116
|
+
*/
|
|
117
|
+
export type ExtractType<T extends string> =
|
|
118
|
+
T extends "string" ? string :
|
|
119
|
+
T extends "number" ? number :
|
|
120
|
+
T extends "boolean" ? boolean :
|
|
121
|
+
T extends "object" ? object :
|
|
122
|
+
T extends "array" ? any[] :
|
|
123
|
+
never;
|
|
124
|
+
|
|
125
|
+
export type IsOptional<T> = T extends { required: false } ? true :
|
|
126
|
+
T extends { default: any } ? true : false;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Doc is a utility type that transforms a schema type into a document type where each property is mapped to its extracted type.
|
|
130
|
+
*
|
|
131
|
+
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
132
|
+
*
|
|
133
|
+
* type Document = Doc<Schema>; // Document is { name: string; age: number; }
|
|
134
|
+
*/
|
|
135
|
+
export type Doc<T extends SchemaType> = {
|
|
136
|
+
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
|
|
137
|
+
ExtractType<T["properties"][K]["type"]>
|
|
138
|
+
} & {
|
|
139
|
+
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends false ? K : never]:
|
|
140
|
+
ExtractType<T["properties"][K]["type"]>
|
|
141
|
+
} & {
|
|
142
|
+
__version?: number;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type QueryOptions = {
|
|
146
|
+
limit?: number;
|
|
147
|
+
offset?: number;
|
|
95
148
|
}
|
|
96
149
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Collection is a class that represents a collection of documents in a database.
|
|
152
|
+
* @template T - A schema type defining the structure of the documents in the collection.
|
|
153
|
+
*/
|
|
154
|
+
export class Collection<T extends SchemaType> {
|
|
155
|
+
/**
|
|
156
|
+
* Finds all documents in the collection.
|
|
157
|
+
*
|
|
158
|
+
* @returns A promise that resolves to an array of documents.
|
|
159
|
+
*/
|
|
160
|
+
find(query: QueryType<T>, options?: QueryOptions): Promise<Doc<T>[]>;
|
|
161
|
+
/**
|
|
162
|
+
* count all documents in the collection.
|
|
163
|
+
*
|
|
164
|
+
* @returns A promise that resolves to an array of documents.
|
|
165
|
+
*/
|
|
166
|
+
count(query: QueryType<T>, options?: QueryOptions): Promise<number>;
|
|
167
|
+
/**
|
|
168
|
+
* Finds a single document in the collection by its ID.
|
|
169
|
+
*
|
|
170
|
+
* @param id - The ID of the document to find.
|
|
171
|
+
* @returns A promise that resolves to the found document.
|
|
172
|
+
*/
|
|
173
|
+
findById(id: string): Promise<Doc<T>>;
|
|
174
|
+
/**
|
|
175
|
+
* Updates a document in the collection by its ID.
|
|
176
|
+
*
|
|
177
|
+
* @param id - The ID of the document to update.
|
|
178
|
+
* @param document - A partial document containing the fields to update.
|
|
179
|
+
* @returns A promise that resolves when the update is complete.
|
|
180
|
+
*/
|
|
181
|
+
update(document: Partial<Doc<T>>): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Creates a new document in the collection.
|
|
184
|
+
*
|
|
185
|
+
* @param document - The document to create.
|
|
186
|
+
* @returns A promise that resolves to the created document.
|
|
187
|
+
*/
|
|
188
|
+
create(document: Doc<T>): Promise<Doc<T>>;
|
|
189
|
+
/**
|
|
190
|
+
* Deletes a document in the collection by its ID.
|
|
191
|
+
*
|
|
192
|
+
* @param id - The ID of the document to delete.
|
|
193
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
194
|
+
*/
|
|
195
|
+
delete(id: string): Promise<void>;
|
|
126
196
|
}
|
|
127
197
|
|
|
128
198
|
|
|
129
199
|
|
|
200
|
+
|
|
130
201
|
/**
|
|
131
202
|
* Represents a property within a schema, including various constraints and nested properties.
|
|
132
203
|
*/
|
|
@@ -191,38 +262,6 @@ export class Property {
|
|
|
191
262
|
|
|
192
263
|
|
|
193
264
|
|
|
194
|
-
/**
|
|
195
|
-
* Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
|
|
196
|
-
*/
|
|
197
|
-
export type SchemaTypeRecord = {
|
|
198
|
-
[name: string]: SchemaType
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
|
|
202
|
-
constructor(
|
|
203
|
-
name: string,
|
|
204
|
-
schemas: Schemas
|
|
205
|
-
);
|
|
206
|
-
abstract start(): Promise<void>;
|
|
207
|
-
abstract close(): Promise<void>;
|
|
208
|
-
abstract count(
|
|
209
|
-
colectionName: keyof Schemas,
|
|
210
|
-
query: QueryType<Schemas[keyof Schemas]>
|
|
211
|
-
): Promise<number>;
|
|
212
|
-
abstract findDocumentById(
|
|
213
|
-
collectionName: keyof Schemas,
|
|
214
|
-
id: string
|
|
215
|
-
): Promise<Doc<Schemas[keyof Schemas]> | undefined | null>;
|
|
216
|
-
abstract find(
|
|
217
|
-
collectionName: keyof Schemas,
|
|
218
|
-
query: QueryType<Schemas[keyof Schemas]>
|
|
219
|
-
): Promise<Doc<Schemas[keyof Schemas]>[]>;
|
|
220
|
-
abstract write(
|
|
221
|
-
op: Operation<Schemas[keyof Schemas]>
|
|
222
|
-
): Promise<Doc<Schemas[keyof Schemas]>>;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
265
|
/**
|
|
227
266
|
* Represents an IndexDB storage system extending the base storage functionality.
|
|
228
267
|
*
|
|
@@ -354,95 +393,6 @@ export class Schema<T extends SchemaType> {
|
|
|
354
393
|
|
|
355
394
|
|
|
356
395
|
|
|
357
|
-
/**
|
|
358
|
-
* Represents an in-memory storage system extending the base storage functionality.
|
|
359
|
-
*
|
|
360
|
-
* @template T - The schema type.
|
|
361
|
-
*/
|
|
362
|
-
export class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
363
|
-
/**
|
|
364
|
-
* Frees the resources used by the in-memory storage.
|
|
365
|
-
*/
|
|
366
|
-
free(): void;
|
|
367
|
-
|
|
368
|
-
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
369
|
-
dbName: string,
|
|
370
|
-
schemas: SchemasCreate,
|
|
371
|
-
): Promise<
|
|
372
|
-
InMemory<
|
|
373
|
-
SchemasCreate
|
|
374
|
-
>
|
|
375
|
-
>;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
export type EnumerateUpTo<
|
|
381
|
-
N extends number,
|
|
382
|
-
Acc extends number[] = []
|
|
383
|
-
> = Acc['length'] extends N ?
|
|
384
|
-
Acc[number]:
|
|
385
|
-
EnumerateUpTo<N, [...Acc, Acc['length']]> ;
|
|
386
|
-
|
|
387
|
-
export type EnumerateFrom1To<
|
|
388
|
-
N extends number
|
|
389
|
-
> = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
|
|
390
|
-
|
|
391
|
-
export type IsVersionGreaterThan0<
|
|
392
|
-
V extends number
|
|
393
|
-
> = V extends 0 ? false : true;
|
|
394
|
-
|
|
395
|
-
export type AnyVersionGreaterThan1<
|
|
396
|
-
T extends Record<string, SchemaType>
|
|
397
|
-
> = true extends {
|
|
398
|
-
[K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
|
|
399
|
-
} [keyof T] ? true : false;
|
|
400
|
-
|
|
401
|
-
export type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
|
|
402
|
-
|
|
403
|
-
export type MigrationPathsForSchema<
|
|
404
|
-
T extends SchemaType
|
|
405
|
-
> = T['version'] extends 0 ? {}: // No migrations needed for version 1
|
|
406
|
-
{
|
|
407
|
-
[K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
export type MigrationPathsForSchemas<
|
|
411
|
-
T extends SchemaTypeRecord
|
|
412
|
-
> = {
|
|
413
|
-
[K in keyof T]: MigrationPathsForSchema<T[K]>;
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
export type MigrationsParameter<
|
|
417
|
-
T extends SchemaTypeRecord
|
|
418
|
-
> = AnyVersionGreaterThan1<T> extends true ?
|
|
419
|
-
{
|
|
420
|
-
migrations: MigrationPathsForSchemas<T>
|
|
421
|
-
}:
|
|
422
|
-
{
|
|
423
|
-
migrations?: never
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
type Hook = (
|
|
429
|
-
schema: Schema<SchemaType>,
|
|
430
|
-
migration: MigrationPathsForSchema<SchemaType>,
|
|
431
|
-
doc: Doc<SchemaType>
|
|
432
|
-
) => Doc<SchemaType>
|
|
433
|
-
|
|
434
|
-
type BasePluginOptions = {
|
|
435
|
-
docCreateHook?: Hook,
|
|
436
|
-
docRecoverHook?: Hook
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
export class BasePlugin implements BasePluginOptions {
|
|
440
|
-
docCreateHook?:Hook;
|
|
441
|
-
docRecoverHook?:Hook;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
396
|
/**
|
|
447
397
|
* Represents a database containing collections of documents.
|
|
448
398
|
* RIDB extends from this class and is used to expose collections.
|
|
@@ -545,100 +495,166 @@ export type RIDBModule = {
|
|
|
545
495
|
|
|
546
496
|
|
|
547
497
|
|
|
548
|
-
export type
|
|
549
|
-
|
|
498
|
+
export type EnumerateUpTo<
|
|
499
|
+
N extends number,
|
|
500
|
+
Acc extends number[] = []
|
|
501
|
+
> = Acc['length'] extends N ?
|
|
502
|
+
Acc[number]:
|
|
503
|
+
EnumerateUpTo<N, [...Acc, Acc['length']]> ;
|
|
504
|
+
|
|
505
|
+
export type EnumerateFrom1To<
|
|
506
|
+
N extends number
|
|
507
|
+
> = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
|
|
508
|
+
|
|
509
|
+
export type IsVersionGreaterThan0<
|
|
510
|
+
V extends number
|
|
511
|
+
> = V extends 0 ? false : true;
|
|
512
|
+
|
|
513
|
+
export type AnyVersionGreaterThan1<
|
|
514
|
+
T extends Record<string, SchemaType>
|
|
515
|
+
> = true extends {
|
|
516
|
+
[K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
|
|
517
|
+
} [keyof T] ? true : false;
|
|
518
|
+
|
|
519
|
+
export type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
|
|
520
|
+
|
|
521
|
+
export type MigrationPathsForSchema<
|
|
522
|
+
T extends SchemaType
|
|
523
|
+
> = T['version'] extends 0 ? {}: // No migrations needed for version 1
|
|
524
|
+
{
|
|
525
|
+
[K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
export type MigrationPathsForSchemas<
|
|
529
|
+
T extends SchemaTypeRecord
|
|
530
|
+
> = {
|
|
531
|
+
[K in keyof T]: MigrationPathsForSchema<T[K]>;
|
|
550
532
|
};
|
|
533
|
+
|
|
534
|
+
export type MigrationsParameter<
|
|
535
|
+
T extends SchemaTypeRecord
|
|
536
|
+
> = AnyVersionGreaterThan1<T> extends true ?
|
|
537
|
+
{
|
|
538
|
+
migrations: MigrationPathsForSchemas<T>
|
|
539
|
+
}:
|
|
540
|
+
{
|
|
541
|
+
migrations?: never
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
551
546
|
/**
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
* @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
|
|
547
|
+
* Represents an in-memory storage system extending the base storage functionality.
|
|
555
548
|
*
|
|
556
|
-
* @
|
|
557
|
-
* type StringType = ExtractType<'string'>; // StringType is string
|
|
558
|
-
* type NumberType = ExtractType<'number'>; // NumberType is number
|
|
559
|
-
* type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
|
|
560
|
-
* type ObjectType = ExtractType<'object'>; // ObjectType is object
|
|
561
|
-
* type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
|
|
549
|
+
* @template T - The schema type.
|
|
562
550
|
*/
|
|
563
|
-
export
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
551
|
+
export class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
552
|
+
/**
|
|
553
|
+
* Frees the resources used by the in-memory storage.
|
|
554
|
+
*/
|
|
555
|
+
free(): void;
|
|
556
|
+
|
|
557
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
558
|
+
dbName: string,
|
|
559
|
+
schemas: SchemasCreate,
|
|
560
|
+
): Promise<
|
|
561
|
+
InMemory<
|
|
562
|
+
SchemasCreate
|
|
563
|
+
>
|
|
564
|
+
>;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
type Hook = (
|
|
570
|
+
schema: Schema<SchemaType>,
|
|
571
|
+
migration: MigrationPathsForSchema<SchemaType>,
|
|
572
|
+
doc: Doc<SchemaType>
|
|
573
|
+
) => Doc<SchemaType>
|
|
574
|
+
|
|
575
|
+
type BasePluginOptions = {
|
|
576
|
+
docCreateHook?: Hook,
|
|
577
|
+
docRecoverHook?: Hook
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
export class BasePlugin implements BasePluginOptions {
|
|
581
|
+
docCreateHook?:Hook;
|
|
582
|
+
docRecoverHook?:Hook;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
export type BaseStorageOptions = {
|
|
588
|
+
[name:string]:string | boolean | number
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInternal<Schemas> {
|
|
592
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
593
|
+
dbName: string,
|
|
594
|
+
schemas: SchemasCreate,
|
|
595
|
+
options?: BaseStorageOptions
|
|
596
|
+
): Promise<
|
|
597
|
+
BaseStorage<
|
|
598
|
+
SchemasCreate
|
|
599
|
+
>
|
|
600
|
+
>;
|
|
601
|
+
constructor(
|
|
602
|
+
dbName: string,
|
|
603
|
+
schemas: Schemas,
|
|
604
|
+
options?: BaseStorageOptions
|
|
605
|
+
);
|
|
606
|
+
readonly dbName: string;
|
|
607
|
+
readonly schemas: Record<keyof Schemas, Schema<Schemas[keyof Schemas]>>;
|
|
608
|
+
readonly options: BaseStorageOptions;
|
|
609
|
+
readonly core: CoreStorage;
|
|
610
|
+
start(): Promise<void>;
|
|
611
|
+
close(): Promise<void>;
|
|
612
|
+
count(colectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<number>;
|
|
613
|
+
findDocumentById(collectionName: keyof Schemas, id: string): Promise<Doc<Schemas[keyof Schemas]> | null | undefined>;
|
|
614
|
+
find(collectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<Doc<Schemas[keyof Schemas]>[]>;
|
|
615
|
+
write(op: Operation<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>>;
|
|
616
|
+
getOption(name: string): string | boolean | number | undefined;
|
|
617
|
+
getSchema(name: string): Schema<any>;
|
|
618
|
+
//Call addIndexSchemas if you need extra indexing schemas for your database
|
|
619
|
+
addIndexSchemas(): null
|
|
620
|
+
}
|
|
621
|
+
|
|
570
622
|
|
|
571
|
-
export type IsOptional<T> = T extends { required: false } ? true :
|
|
572
|
-
T extends { default: any } ? true : false;
|
|
573
623
|
|
|
574
624
|
/**
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
578
|
-
*
|
|
579
|
-
* type Document = Doc<Schema>; // Document is { name: string; age: number; }
|
|
625
|
+
* Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
|
|
580
626
|
*/
|
|
581
|
-
export type
|
|
582
|
-
|
|
583
|
-
ExtractType<T["properties"][K]["type"]>
|
|
584
|
-
} & {
|
|
585
|
-
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends false ? K : never]:
|
|
586
|
-
ExtractType<T["properties"][K]["type"]>
|
|
587
|
-
} & {
|
|
588
|
-
__version?: number;
|
|
627
|
+
export type SchemaTypeRecord = {
|
|
628
|
+
[name: string]: SchemaType
|
|
589
629
|
};
|
|
590
630
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
* Updates a document in the collection by its ID.
|
|
617
|
-
*
|
|
618
|
-
* @param id - The ID of the document to update.
|
|
619
|
-
* @param document - A partial document containing the fields to update.
|
|
620
|
-
* @returns A promise that resolves when the update is complete.
|
|
621
|
-
*/
|
|
622
|
-
update(document: Partial<Doc<T>>): Promise<void>;
|
|
623
|
-
/**
|
|
624
|
-
* Creates a new document in the collection.
|
|
625
|
-
*
|
|
626
|
-
* @param document - The document to create.
|
|
627
|
-
* @returns A promise that resolves to the created document.
|
|
628
|
-
*/
|
|
629
|
-
create(document: Doc<T>): Promise<Doc<T>>;
|
|
630
|
-
/**
|
|
631
|
-
* Deletes a document in the collection by its ID.
|
|
632
|
-
*
|
|
633
|
-
* @param id - The ID of the document to delete.
|
|
634
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
635
|
-
*/
|
|
636
|
-
delete(id: string): Promise<void>;
|
|
631
|
+
export abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
|
|
632
|
+
constructor(
|
|
633
|
+
name: string,
|
|
634
|
+
schemas: Schemas
|
|
635
|
+
);
|
|
636
|
+
abstract start(): Promise<void>;
|
|
637
|
+
abstract close(): Promise<void>;
|
|
638
|
+
abstract count(
|
|
639
|
+
colectionName: keyof Schemas,
|
|
640
|
+
query: QueryType<Schemas[keyof Schemas]>,
|
|
641
|
+
options?: QueryOptions
|
|
642
|
+
): Promise<number>;
|
|
643
|
+
abstract findDocumentById(
|
|
644
|
+
collectionName: keyof Schemas,
|
|
645
|
+
id: string
|
|
646
|
+
): Promise<Doc<Schemas[keyof Schemas]> | undefined | null>;
|
|
647
|
+
abstract find(
|
|
648
|
+
collectionName: keyof Schemas,
|
|
649
|
+
query: QueryType<Schemas[keyof Schemas]>,
|
|
650
|
+
options?: QueryOptions
|
|
651
|
+
): Promise<Doc<Schemas[keyof Schemas]>[]>;
|
|
652
|
+
abstract write(
|
|
653
|
+
op: Operation<Schemas[keyof Schemas]>
|
|
654
|
+
): Promise<Doc<Schemas[keyof Schemas]>>;
|
|
637
655
|
}
|
|
638
656
|
|
|
639
657
|
|
|
640
|
-
|
|
641
|
-
|
|
642
658
|
export class CoreStorage {
|
|
643
659
|
/**
|
|
644
660
|
* @param {any} document
|
|
@@ -750,12 +766,22 @@ export interface InitOutput {
|
|
|
750
766
|
readonly __wbgt_test_query_parse_multiple_operators_26: (a: number) => void;
|
|
751
767
|
readonly __wbgt_test_query_parse_invalid_in_operator_27: (a: number) => void;
|
|
752
768
|
readonly __wbgt_test_query_parse_empty_logical_operators_28: (a: number) => void;
|
|
753
|
-
readonly
|
|
754
|
-
readonly
|
|
755
|
-
readonly
|
|
756
|
-
readonly
|
|
757
|
-
readonly
|
|
758
|
-
readonly
|
|
769
|
+
readonly __wbgt_test_query_parse_nin_operator_29: (a: number) => void;
|
|
770
|
+
readonly __wbgt_test_query_parse_nin_operator_wrong_type_30: (a: number) => void;
|
|
771
|
+
readonly __wbgt_test_query_parse_eq_operator_31: (a: number) => void;
|
|
772
|
+
readonly __wbgt_test_query_parse_eq_operator_wrong_type_32: (a: number) => void;
|
|
773
|
+
readonly __wbgt_test_query_parse_ne_operator_33: (a: number) => void;
|
|
774
|
+
readonly __wbgt_test_query_parse_ne_operator_wrong_type_34: (a: number) => void;
|
|
775
|
+
readonly __wbg_collection_free: (a: number) => void;
|
|
776
|
+
readonly collection_name: (a: number, b: number) => void;
|
|
777
|
+
readonly collection_schema: (a: number, b: number) => void;
|
|
778
|
+
readonly collection_find: (a: number, b: number, c: number) => number;
|
|
779
|
+
readonly collection_parse_query_options: (a: number, b: number, c: number) => void;
|
|
780
|
+
readonly collection_count: (a: number, b: number, c: number) => number;
|
|
781
|
+
readonly collection_findById: (a: number, b: number) => number;
|
|
782
|
+
readonly collection_update: (a: number, b: number) => number;
|
|
783
|
+
readonly collection_create: (a: number, b: number) => number;
|
|
784
|
+
readonly collection_delete: (a: number, b: number) => number;
|
|
759
785
|
readonly __wbg_property_free: (a: number) => void;
|
|
760
786
|
readonly property_is_valid: (a: number, b: number) => void;
|
|
761
787
|
readonly property_type: (a: number) => number;
|
|
@@ -773,9 +799,9 @@ export interface InitOutput {
|
|
|
773
799
|
readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
|
|
774
800
|
readonly indexdb_create: (a: number, b: number, c: number) => number;
|
|
775
801
|
readonly indexdb_write: (a: number, b: number) => number;
|
|
776
|
-
readonly indexdb_find: (a: number, b: number, c: number, d: number) => number;
|
|
802
|
+
readonly indexdb_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
777
803
|
readonly indexdb_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
778
|
-
readonly indexdb_count: (a: number, b: number, c: number, d: number) => number;
|
|
804
|
+
readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
779
805
|
readonly indexdb_close: (a: number) => number;
|
|
780
806
|
readonly indexdb_start: (a: number) => number;
|
|
781
807
|
readonly __wbg_schema_free: (a: number) => void;
|
|
@@ -791,12 +817,21 @@ export interface InitOutput {
|
|
|
791
817
|
readonly __wbgt_test_schema_creation_3: (a: number) => void;
|
|
792
818
|
readonly __wbgt_test_schema_validation_4: (a: number) => void;
|
|
793
819
|
readonly __wbgt_test_invalid_schema_5: (a: number) => void;
|
|
820
|
+
readonly __wbg_database_free: (a: number) => void;
|
|
821
|
+
readonly database_start: (a: number) => number;
|
|
822
|
+
readonly database_close: (a: number) => number;
|
|
823
|
+
readonly database_started: (a: number) => number;
|
|
824
|
+
readonly database_collections: (a: number, b: number) => void;
|
|
825
|
+
readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
826
|
+
readonly __wbg_queryoptions_free: (a: number) => void;
|
|
827
|
+
readonly queryoptions_limit: (a: number, b: number) => void;
|
|
828
|
+
readonly queryoptions_offset: (a: number, b: number) => void;
|
|
794
829
|
readonly __wbg_inmemory_free: (a: number) => void;
|
|
795
830
|
readonly inmemory_create: (a: number, b: number, c: number) => number;
|
|
796
831
|
readonly inmemory_write: (a: number, b: number) => number;
|
|
797
|
-
readonly inmemory_find: (a: number, b: number, c: number, d: number) => number;
|
|
832
|
+
readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
798
833
|
readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
799
|
-
readonly inmemory_count: (a: number, b: number, c: number, d: number) => number;
|
|
834
|
+
readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
800
835
|
readonly inmemory_close: (a: number) => number;
|
|
801
836
|
readonly inmemory_start: (a: number) => number;
|
|
802
837
|
readonly __wbg_baseplugin_free: (a: number) => void;
|
|
@@ -806,21 +841,12 @@ export interface InitOutput {
|
|
|
806
841
|
readonly baseplugin_get_doc_recover_hook: (a: number) => number;
|
|
807
842
|
readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
|
|
808
843
|
readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
|
|
809
|
-
readonly
|
|
810
|
-
readonly
|
|
811
|
-
readonly
|
|
812
|
-
readonly
|
|
813
|
-
readonly
|
|
814
|
-
readonly
|
|
815
|
-
readonly __wbg_collection_free: (a: number) => void;
|
|
816
|
-
readonly collection_name: (a: number, b: number) => void;
|
|
817
|
-
readonly collection_schema: (a: number, b: number) => void;
|
|
818
|
-
readonly collection_find: (a: number, b: number) => number;
|
|
819
|
-
readonly collection_count: (a: number, b: number) => number;
|
|
820
|
-
readonly collection_findById: (a: number, b: number) => number;
|
|
821
|
-
readonly collection_update: (a: number, b: number) => number;
|
|
822
|
-
readonly collection_create: (a: number, b: number) => number;
|
|
823
|
-
readonly collection_delete: (a: number, b: number) => number;
|
|
844
|
+
readonly __wbg_basestorage_free: (a: number) => void;
|
|
845
|
+
readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
846
|
+
readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
|
|
847
|
+
readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
|
|
848
|
+
readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
|
|
849
|
+
readonly basestorage_core: (a: number, b: number) => void;
|
|
824
850
|
readonly corestorage_new: () => number;
|
|
825
851
|
readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
|
|
826
852
|
readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -832,9 +858,9 @@ export interface InitOutput {
|
|
|
832
858
|
readonly operation_primaryKeyField: (a: number) => number;
|
|
833
859
|
readonly operation_primaryKey: (a: number) => number;
|
|
834
860
|
readonly operation_primaryKeyIndex: (a: number, b: number) => void;
|
|
835
|
-
readonly __wbg_corestorage_free: (a: number) => void;
|
|
836
861
|
readonly main_js: () => void;
|
|
837
862
|
readonly is_debug_mode: () => number;
|
|
863
|
+
readonly __wbg_corestorage_free: (a: number) => void;
|
|
838
864
|
readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
|
|
839
865
|
readonly wasmbindgentestcontext_new: () => number;
|
|
840
866
|
readonly wasmbindgentestcontext_args: (a: number, b: number, c: number) => void;
|
|
@@ -847,10 +873,10 @@ export interface InitOutput {
|
|
|
847
873
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
848
874
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
849
875
|
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
876
|
+
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0b4dc78d20138ec8: (a: number, b: number, c: number) => void;
|
|
850
877
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
851
|
-
readonly
|
|
852
|
-
readonly
|
|
853
|
-
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfb3063b9244661be: (a: number, b: number, c: number) => number;
|
|
878
|
+
readonly _dyn_core__ops__function__Fn__A_B_C___Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdcf54b3c6e50bf47: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
879
|
+
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9ad206a193337a57: (a: number, b: number, c: number) => number;
|
|
854
880
|
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hc0ac713d063ee923: (a: number, b: number, c: number) => void;
|
|
855
881
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
856
882
|
readonly __wbindgen_exn_store: (a: number) => void;
|