@liorandb/core 1.0.14 → 1.0.16
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/dist/index.d.ts +23 -15
- package/dist/index.js +586 -277
- package/package.json +5 -2
- package/src/LioranManager.ts +67 -8
- package/src/core/collection.ts +193 -127
- package/src/core/compaction.ts +123 -0
- package/src/core/database.ts +75 -21
- package/src/core/query.ts +2 -0
- package/src/ipc/index.ts +39 -0
- package/src/ipc/queue.ts +48 -1
- package/src/ipc/server.ts +70 -7
- package/src/utils/tar.ts +89 -0
package/dist/index.d.ts
CHANGED
|
@@ -37,30 +37,28 @@ declare class Collection<T = any> {
|
|
|
37
37
|
private validate;
|
|
38
38
|
private _enqueue;
|
|
39
39
|
close(): Promise<void>;
|
|
40
|
+
compact(): Promise<void>;
|
|
40
41
|
_exec(op: string, args: any[]): Promise<any>;
|
|
41
|
-
insertOne(doc: T & {
|
|
42
|
-
_id?: string;
|
|
43
|
-
}): Promise<any>;
|
|
44
|
-
insertMany(docs?: (T & {
|
|
45
|
-
_id?: string;
|
|
46
|
-
})[]): Promise<any>;
|
|
47
|
-
find(query?: any): Promise<any>;
|
|
48
|
-
findOne(query?: any): Promise<any>;
|
|
49
|
-
updateOne(filter: any, update: any, options?: UpdateOptions$1): Promise<any>;
|
|
50
|
-
updateMany(filter: any, update: any): Promise<any>;
|
|
51
|
-
deleteOne(filter: any): Promise<any>;
|
|
52
|
-
deleteMany(filter: any): Promise<any>;
|
|
53
|
-
countDocuments(filter?: any): Promise<any>;
|
|
54
42
|
private _updateIndexes;
|
|
55
43
|
private _insertOne;
|
|
56
44
|
private _insertMany;
|
|
45
|
+
private _getCandidateIds;
|
|
46
|
+
private _find;
|
|
57
47
|
private _findOne;
|
|
48
|
+
private _countDocuments;
|
|
58
49
|
private _updateOne;
|
|
59
50
|
private _updateMany;
|
|
60
|
-
private _find;
|
|
61
51
|
private _deleteOne;
|
|
62
52
|
private _deleteMany;
|
|
63
|
-
|
|
53
|
+
insertOne(doc: any): Promise<any>;
|
|
54
|
+
insertMany(docs: any[]): Promise<any>;
|
|
55
|
+
find(query?: any): Promise<any>;
|
|
56
|
+
findOne(query?: any): Promise<any>;
|
|
57
|
+
updateOne(filter: any, update: any, options?: UpdateOptions$1): Promise<any>;
|
|
58
|
+
updateMany(filter: any, update: any): Promise<any>;
|
|
59
|
+
deleteOne(filter: any): Promise<any>;
|
|
60
|
+
deleteMany(filter: any): Promise<any>;
|
|
61
|
+
countDocuments(filter?: any): Promise<any>;
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
type TXOp = {
|
|
@@ -104,6 +102,8 @@ declare class LioranDB {
|
|
|
104
102
|
applyTransaction(ops: TXOp[]): Promise<void>;
|
|
105
103
|
collection<T = any>(name: string, schema?: ZodSchema<T>): Collection<T>;
|
|
106
104
|
createIndex(collection: string, field: string, options?: IndexOptions): Promise<void>;
|
|
105
|
+
compactCollection(name: string): Promise<void>;
|
|
106
|
+
compactAll(): Promise<void>;
|
|
107
107
|
transaction<T>(fn: (tx: DBTransactionContext) => Promise<T>): Promise<T>;
|
|
108
108
|
close(): Promise<void>;
|
|
109
109
|
}
|
|
@@ -124,6 +124,14 @@ declare class LioranManager {
|
|
|
124
124
|
private tryAcquireLock;
|
|
125
125
|
db(name: string): Promise<LioranDB>;
|
|
126
126
|
openDatabase(name: string): Promise<LioranDB>;
|
|
127
|
+
/**
|
|
128
|
+
* Create TAR snapshot of full DB directory
|
|
129
|
+
*/
|
|
130
|
+
snapshot(snapshotPath: string): Promise<unknown>;
|
|
131
|
+
/**
|
|
132
|
+
* Restore TAR snapshot safely
|
|
133
|
+
*/
|
|
134
|
+
restore(snapshotPath: string): Promise<unknown>;
|
|
127
135
|
closeAll(): Promise<void>;
|
|
128
136
|
close(): Promise<void>;
|
|
129
137
|
private _registerShutdownHooks;
|