@wxn0brp/db 0.9.1 → 0.20.1

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.
Files changed (89) hide show
  1. package/LICENSE +1 -1
  2. package/dist/{helpers/autoCreate.d.ts → autoCreate.d.ts} +2 -2
  3. package/dist/{helpers/autoCreate.js → autoCreate.js} +2 -2
  4. package/dist/{db/graph.d.ts → graph.d.ts} +1 -1
  5. package/dist/index.d.ts +8 -15
  6. package/dist/index.js +7 -10
  7. package/dist/valthera.d.ts +7 -0
  8. package/dist/valthera.js +14 -0
  9. package/dist/version.js +1 -1
  10. package/package.json +11 -21
  11. package/dist/actions/action.d.ts +0 -74
  12. package/dist/actions/action.js +0 -245
  13. package/dist/actions/memory.d.ts +0 -72
  14. package/dist/actions/memory.js +0 -135
  15. package/dist/base/actions.d.ts +0 -19
  16. package/dist/base/actions.js +0 -64
  17. package/dist/base/db.d.ts +0 -23
  18. package/dist/base/db.js +0 -64
  19. package/dist/client/function.d.ts +0 -5
  20. package/dist/client/function.js +0 -30
  21. package/dist/client/graph.d.ts +0 -54
  22. package/dist/client/graph.js +0 -108
  23. package/dist/client/remote.d.ts +0 -15
  24. package/dist/client/remote.js +0 -1
  25. package/dist/client/valthera.d.ts +0 -83
  26. package/dist/client/valthera.js +0 -148
  27. package/dist/db/valthera.d.ts +0 -84
  28. package/dist/db/valthera.js +0 -122
  29. package/dist/file/customFileCpu.d.ts +0 -21
  30. package/dist/file/customFileCpu.js +0 -74
  31. package/dist/file/find.d.ts +0 -12
  32. package/dist/file/find.js +0 -100
  33. package/dist/file/index.d.ts +0 -3
  34. package/dist/file/index.js +0 -19
  35. package/dist/file/remove.d.ts +0 -7
  36. package/dist/file/remove.js +0 -41
  37. package/dist/file/transactions.d.ts +0 -3
  38. package/dist/file/transactions.js +0 -119
  39. package/dist/file/update.d.ts +0 -7
  40. package/dist/file/update.js +0 -50
  41. package/dist/file/utils.d.ts +0 -8
  42. package/dist/file/utils.js +0 -84
  43. package/dist/helpers/CollectionManager.d.ts +0 -47
  44. package/dist/helpers/CollectionManager.js +0 -63
  45. package/dist/helpers/executor.d.ts +0 -28
  46. package/dist/helpers/executor.js +0 -45
  47. package/dist/helpers/format.d.ts +0 -12
  48. package/dist/helpers/format.js +0 -23
  49. package/dist/helpers/gen.d.ts +0 -8
  50. package/dist/helpers/gen.js +0 -134
  51. package/dist/helpers/relation.d.ts +0 -10
  52. package/dist/helpers/relation.js +0 -155
  53. package/dist/helpers/updateOneOrAdd.d.ts +0 -2
  54. package/dist/helpers/updateOneOrAdd.js +0 -18
  55. package/dist/types/Id.d.ts +0 -3
  56. package/dist/types/Id.js +0 -1
  57. package/dist/types/arg.d.ts +0 -12
  58. package/dist/types/arg.js +0 -1
  59. package/dist/types/data.d.ts +0 -4
  60. package/dist/types/data.js +0 -1
  61. package/dist/types/export.d.ts +0 -11
  62. package/dist/types/export.js +0 -1
  63. package/dist/types/fileCpu.d.ts +0 -69
  64. package/dist/types/fileCpu.js +0 -1
  65. package/dist/types/options.d.ts +0 -16
  66. package/dist/types/options.js +0 -1
  67. package/dist/types/query.d.ts +0 -17
  68. package/dist/types/query.js +0 -1
  69. package/dist/types/relation.d.ts +0 -28
  70. package/dist/types/relation.js +0 -1
  71. package/dist/types/searchOpts.d.ts +0 -62
  72. package/dist/types/searchOpts.js +0 -7
  73. package/dist/types/transactions.d.ts +0 -10
  74. package/dist/types/transactions.js +0 -1
  75. package/dist/types/types.d.ts +0 -3
  76. package/dist/types/types.js +0 -1
  77. package/dist/types/updater.d.ts +0 -26
  78. package/dist/types/updater.js +0 -4
  79. package/dist/types/valthera.d.ts +0 -41
  80. package/dist/types/valthera.js +0 -1
  81. package/dist/utils/hasFields.d.ts +0 -7
  82. package/dist/utils/hasFields.js +0 -18
  83. package/dist/utils/hasFieldsAdvanced.d.ts +0 -5
  84. package/dist/utils/hasFieldsAdvanced.js +0 -176
  85. package/dist/utils/updateFindObject.d.ts +0 -11
  86. package/dist/utils/updateFindObject.js +0 -28
  87. package/dist/utils/updateObject.d.ts +0 -7
  88. package/dist/utils/updateObject.js +0 -145
  89. /package/dist/{db/graph.js → graph.js} +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 wxn0brP
3
+ Copyright (c) 2025 wxn0brP
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
- import { Remote } from "../client/remote.js";
2
- import { ValtheraCompatible } from "../types/valthera.js";
1
+ import { Remote } from "@wxn0brp/db-client/remote";
2
+ import { ValtheraCompatible } from "@wxn0brp/db-core/types/valthera";
3
3
  /**
4
4
  * Creates a database instance based on the provided configuration.
5
5
  * If the configuration is an object, it creates a DataBaseRemote instance.
@@ -1,5 +1,5 @@
1
- import ValtheraRemote from "../client/valthera.js";
2
- import Valthera from "../db/valthera.js";
1
+ import ValtheraRemote from "@wxn0brp/db-client/valthera";
2
+ import Valthera from "./valthera.js";
3
3
  /**
4
4
  * Creates a database instance based on the provided configuration.
5
5
  * If the configuration is an object, it creates a DataBaseRemote instance.
@@ -1,5 +1,5 @@
1
+ import Data from "@wxn0brp/db-core/types/data";
1
2
  import Valthera from "./valthera.js";
2
- import Data from "../types/data.js";
3
3
  /**
4
4
  * A class representing a graph database.
5
5
  * @class
package/dist/index.d.ts CHANGED
@@ -1,16 +1,9 @@
1
- import Valthera from "./db/valthera.js";
2
- import Graph from "./db/graph.js";
3
- import ValtheraRemote from "./client/valthera.js";
4
- import GraphRemote from "./client/graph.js";
5
- import genId from "./helpers/gen.js";
6
- import Relation from "./helpers/relation.js";
7
- import CustomFileCpu from "./file/customFileCpu.js";
8
- import ValtheraMemory, { createMemoryValthera } from "./actions/memory.js";
9
- import { ValtheraAutoCreate } from "./helpers/autoCreate.js";
10
- import { RelationTypes } from "./types/relation.js";
11
- import { ValtheraCompatible } from "./types/valthera.js";
12
- import { ValtheraTypes } from "./types/export.js";
13
- export { Valthera, Graph, ValtheraRemote, GraphRemote, Relation, genId, CustomFileCpu, ValtheraMemory, createMemoryValthera, ValtheraAutoCreate, };
1
+ import GraphRemote from "@wxn0brp/db-client/graph";
2
+ import { ValtheraAutoCreate } from "./autoCreate.js";
3
+ import Graph from "./graph.js";
4
+ import { Valthera } from "./valthera.js";
14
5
  type GraphCompatible = Graph | GraphRemote;
15
- export type { ValtheraCompatible, RelationTypes, GraphCompatible, ValtheraTypes };
16
- export type Id = import("./types/Id.js").Id;
6
+ export * from "@wxn0brp/db-core";
7
+ export * from "@wxn0brp/db-client";
8
+ export { Graph, GraphCompatible, GraphRemote, Valthera, ValtheraAutoCreate };
9
+ export type Id = import("@wxn0brp/db-core/types/Id").Id;
package/dist/index.js CHANGED
@@ -1,10 +1,7 @@
1
- import Valthera from "./db/valthera.js";
2
- import Graph from "./db/graph.js";
3
- import ValtheraRemote from "./client/valthera.js";
4
- import GraphRemote from "./client/graph.js";
5
- import genId from "./helpers/gen.js";
6
- import Relation from "./helpers/relation.js";
7
- import CustomFileCpu from "./file/customFileCpu.js";
8
- import ValtheraMemory, { createMemoryValthera } from "./actions/memory.js";
9
- import { ValtheraAutoCreate } from "./helpers/autoCreate.js";
10
- export { Valthera, Graph, ValtheraRemote, GraphRemote, Relation, genId, CustomFileCpu, ValtheraMemory, createMemoryValthera, ValtheraAutoCreate, };
1
+ import GraphRemote from "@wxn0brp/db-client/graph";
2
+ import { ValtheraAutoCreate } from "./autoCreate.js";
3
+ import Graph from "./graph.js";
4
+ import { Valthera } from "./valthera.js";
5
+ export * from "@wxn0brp/db-core";
6
+ export * from "@wxn0brp/db-client";
7
+ export { Graph, GraphRemote, Valthera, ValtheraAutoCreate };
@@ -0,0 +1,7 @@
1
+ import ValtheraClass from "@wxn0brp/db-core/db/valthera";
2
+ import FileCpu from "@wxn0brp/db-core/types/fileCpu";
3
+ import { DbOpts } from "@wxn0brp/db-core/types/options";
4
+ export declare class Valthera extends ValtheraClass {
5
+ constructor(folder: string, options?: DbOpts, fileCpu?: FileCpu);
6
+ }
7
+ export default Valthera;
@@ -0,0 +1,14 @@
1
+ import ValtheraClass from "@wxn0brp/db-core/db/valthera";
2
+ import executorC from "@wxn0brp/db-core/helpers/executor";
3
+ import dbActionC from "@wxn0brp/db-plugin-dir/action";
4
+ import vFileCpu from "@wxn0brp/db-plugin-dir/file/index";
5
+ export class Valthera extends ValtheraClass {
6
+ constructor(folder, options = {}, fileCpu) {
7
+ super(options);
8
+ if (!fileCpu)
9
+ fileCpu = vFileCpu;
10
+ this.dbAction = options.dbAction || new dbActionC(folder, options, fileCpu);
11
+ this.executor = options.executor || new executorC();
12
+ }
13
+ }
14
+ export default Valthera;
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "0.9.1";
1
+ export const version = "0.20.1";
package/package.json CHANGED
@@ -1,32 +1,20 @@
1
1
  {
2
2
  "name": "@wxn0brp/db",
3
- "version": "0.9.1",
3
+ "version": "0.20.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
- "description": "A simple file-based database management system with support for CRUD operations, custom queries, and graph structures.",
7
- "homepage": "https://github.com/wxn0brP/ValtheraDB",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/wxn0brP/ValtheraDB.git"
11
- },
12
- "keywords": [
13
- "database",
14
- "file-based",
15
- "CRUD",
16
- "graph",
17
- "query"
18
- ],
19
6
  "author": "wxn0brP",
20
7
  "license": "MIT",
21
8
  "type": "module",
22
9
  "dependencies": {
23
- "json5": "^2.2.3",
24
- "ky": "^1.7.4"
10
+ "@wxn0brp/db-core": ">=0.0.1 <0.1.0",
11
+ "@wxn0brp/db-client": ">=0.0.1 <0.1.0",
12
+ "@wxn0brp/db-plugin-dir": ">=0.0.1 <0.1.0"
25
13
  },
26
14
  "devDependencies": {
27
- "@types/node": "^22.10.2",
15
+ "@types/node": "^22.12.0",
28
16
  "tsc-alias": "^1.8.10",
29
- "typescript": "^5.7.2"
17
+ "typescript": "^5.7.3"
30
18
  },
31
19
  "files": [
32
20
  "dist"
@@ -34,11 +22,13 @@
34
22
  "exports": {
35
23
  ".": {
36
24
  "types": "./dist/index.d.ts",
37
- "import": "./dist/index.js"
25
+ "import": "./dist/index.js",
26
+ "default": "./dist/index.js"
38
27
  },
39
28
  "./*": {
40
- "types": "./dist/*",
41
- "import": "./dist/*"
29
+ "types": "./dist/*.d.ts",
30
+ "import": "./dist/*.js",
31
+ "default": "./dist/*.js"
42
32
  }
43
33
  }
44
34
  }
@@ -1,74 +0,0 @@
1
- import dbActionBase from "../base/actions.js";
2
- import Data from "../types/data.js";
3
- import FileCpu from "../types/fileCpu.js";
4
- import { DbOpts } from "../types/options.js";
5
- import { VQuery } from "../types/query.js";
6
- /**
7
- * A class representing database actions on files.
8
- * @class
9
- */
10
- declare class dbActionC extends dbActionBase {
11
- folder: string;
12
- options: DbOpts;
13
- fileCpu: FileCpu;
14
- /**
15
- * Creates a new instance of dbActionC.
16
- * @constructor
17
- * @param folder - The folder where database files are stored.
18
- * @param options - The options object.
19
- */
20
- constructor(folder: string, options: DbOpts, fileCpu: FileCpu);
21
- _getCollectionPath(collection: string): string;
22
- /**
23
- * Get a list of available databases in the specified folder.
24
- */
25
- getCollections(): Promise<string[]>;
26
- /**
27
- * Check and create the specified collection if it doesn't exist.
28
- */
29
- checkCollection({ collection }: VQuery): Promise<boolean>;
30
- /**
31
- * Check if a collection exists.
32
- */
33
- issetCollection({ collection }: VQuery): Promise<boolean>;
34
- /**
35
- * Add a new entry to the specified database.
36
- */
37
- add({ collection, data, id_gen }: VQuery): Promise<import("../types/arg.js").Arg>;
38
- /**
39
- * Find entries in the specified database based on search criteria.
40
- */
41
- find({ collection, search, context, dbFindOpts, findOpts }: VQuery): Promise<any[]>;
42
- /**
43
- * Find the first matching entry in the specified database based on search criteria.
44
- */
45
- findOne({ collection, search, context, findOpts }: VQuery): Promise<Data>;
46
- findStream({ collection, search, context, findOpts, limit }: VQuery): AsyncGenerator<any>;
47
- /**
48
- * Update entries in the specified database based on search criteria and an updater function or object.
49
- */
50
- update({ collection, search, updater, context }: VQuery): Promise<boolean>;
51
- /**
52
- * Update the first matching entry in the specified database based on search criteria and an updater function or object.
53
- */
54
- updateOne({ collection, search, updater, context }: VQuery): Promise<boolean>;
55
- /**
56
- * Remove entries from the specified database based on search criteria.
57
- */
58
- remove({ collection, search, context }: VQuery): Promise<boolean>;
59
- /**
60
- * Remove the first matching entry from the specified database based on search criteria.
61
- */
62
- removeOne({ collection, search, context }: VQuery): Promise<boolean>;
63
- /**
64
- * Removes a database collection from the file system.
65
- */
66
- removeCollection({ collection }: {
67
- collection: any;
68
- }): Promise<boolean>;
69
- /**
70
- * Apply a series of transactions to a database collection.
71
- */
72
- transaction({ collection, transaction }: VQuery): Promise<boolean>;
73
- }
74
- export default dbActionC;
@@ -1,245 +0,0 @@
1
- import { existsSync, mkdirSync, promises, statSync } from "fs";
2
- import dbActionBase from "../base/actions.js";
3
- import gen from "../helpers/gen.js";
4
- import { resolve, sep } from "path";
5
- /**
6
- * A class representing database actions on files.
7
- * @class
8
- */
9
- class dbActionC extends dbActionBase {
10
- folder;
11
- options;
12
- fileCpu;
13
- /**
14
- * Creates a new instance of dbActionC.
15
- * @constructor
16
- * @param folder - The folder where database files are stored.
17
- * @param options - The options object.
18
- */
19
- constructor(folder, options, fileCpu) {
20
- super();
21
- this.folder = folder;
22
- this.options = {
23
- maxFileSize: 2 * 1024 * 1024, //2 MB
24
- ...options,
25
- };
26
- this.fileCpu = fileCpu;
27
- if (!existsSync(folder))
28
- mkdirSync(folder, { recursive: true });
29
- }
30
- _getCollectionPath(collection) {
31
- return this.folder + "/" + collection + "/";
32
- }
33
- /**
34
- * Get a list of available databases in the specified folder.
35
- */
36
- async getCollections() {
37
- const allCollections = await promises.readdir(this.folder, { recursive: true, withFileTypes: true });
38
- const collections = allCollections
39
- .filter(dirent => dirent.isDirectory())
40
- .map(dirent => {
41
- const parentPath = resolve(dirent.parentPath);
42
- const baseFolder = resolve(this.folder);
43
- if (parentPath === baseFolder)
44
- return dirent.name;
45
- return parentPath.replace(baseFolder + sep, "") + "/" + dirent.name;
46
- });
47
- return collections;
48
- }
49
- /**
50
- * Check and create the specified collection if it doesn't exist.
51
- */
52
- async checkCollection({ collection }) {
53
- if (await this.issetCollection(collection))
54
- return;
55
- const cpath = this._getCollectionPath(collection);
56
- await promises.mkdir(cpath, { recursive: true });
57
- return true;
58
- }
59
- /**
60
- * Check if a collection exists.
61
- */
62
- async issetCollection({ collection }) {
63
- const path = this._getCollectionPath(collection);
64
- try {
65
- await promises.access(path);
66
- return true;
67
- }
68
- catch {
69
- return false;
70
- }
71
- }
72
- /**
73
- * Add a new entry to the specified database.
74
- */
75
- async add({ collection, data, id_gen = true }) {
76
- await this.checkCollection(arguments[0]);
77
- const cpath = this._getCollectionPath(collection);
78
- const file = cpath + await getLastFile(cpath, this.options.maxFileSize);
79
- if (id_gen)
80
- data._id = data._id || gen();
81
- await this.fileCpu.add(file, data);
82
- return data;
83
- }
84
- /**
85
- * Find entries in the specified database based on search criteria.
86
- */
87
- async find({ collection, search, context = {}, dbFindOpts = {}, findOpts = {} }) {
88
- dbFindOpts.reverse = dbFindOpts.reverse || false;
89
- dbFindOpts.max = dbFindOpts.max || -1;
90
- await this.checkCollection(arguments[0]);
91
- const cpath = this._getCollectionPath(collection);
92
- const files = await getSortedFiles(cpath);
93
- if (dbFindOpts.reverse)
94
- files.reverse();
95
- let datas = [];
96
- let totalEntries = 0;
97
- for (let f of files) {
98
- let data = await this.fileCpu.find(cpath + f, search, context, findOpts);
99
- if (dbFindOpts.reverse)
100
- data.reverse();
101
- if (dbFindOpts.max !== -1) {
102
- if (totalEntries + data.length > dbFindOpts.max) {
103
- let remainingEntries = dbFindOpts.max - totalEntries;
104
- data = data.slice(0, remainingEntries);
105
- totalEntries = dbFindOpts.max;
106
- }
107
- else {
108
- totalEntries += data.length;
109
- }
110
- }
111
- datas = datas.concat(data);
112
- if (dbFindOpts.max !== -1 && totalEntries >= dbFindOpts.max)
113
- break;
114
- }
115
- return datas;
116
- }
117
- /**
118
- * Find the first matching entry in the specified database based on search criteria.
119
- */
120
- async findOne({ collection, search, context = {}, findOpts = {} }) {
121
- await this.checkCollection(arguments[0]);
122
- const cpath = this._getCollectionPath(collection);
123
- const files = await getSortedFiles(cpath);
124
- for (let f of files) {
125
- let data = await this.fileCpu.findOne(cpath + f, search, context, findOpts);
126
- if (data)
127
- return data;
128
- }
129
- return null;
130
- }
131
- async *findStream({ collection, search, context = {}, findOpts = {}, limit = -1 }) {
132
- await this.checkCollection(arguments[0]);
133
- const cpath = this._getCollectionPath(collection);
134
- const files = await getSortedFiles(cpath);
135
- let count = 0;
136
- for (let f of files) {
137
- for await (const data of this.fileCpu.findStream(cpath + f, search, context, findOpts, limit)) {
138
- yield data;
139
- count++;
140
- if (limit !== -1 && count >= limit) {
141
- return;
142
- }
143
- }
144
- }
145
- }
146
- /**
147
- * Update entries in the specified database based on search criteria and an updater function or object.
148
- */
149
- async update({ collection, search, updater, context = {} }) {
150
- await this.checkCollection(arguments[0]);
151
- return await operationUpdater(this._getCollectionPath(collection), this.fileCpu.update.bind(this.fileCpu), false, search, updater, context);
152
- }
153
- /**
154
- * Update the first matching entry in the specified database based on search criteria and an updater function or object.
155
- */
156
- async updateOne({ collection, search, updater, context = {} }) {
157
- await this.checkCollection(arguments[0]);
158
- return await operationUpdater(this._getCollectionPath(collection), this.fileCpu.update.bind(this.fileCpu), true, search, updater, context);
159
- }
160
- /**
161
- * Remove entries from the specified database based on search criteria.
162
- */
163
- async remove({ collection, search, context = {} }) {
164
- await this.checkCollection(arguments[0]);
165
- return await operationUpdater(this._getCollectionPath(collection), this.fileCpu.remove.bind(this.fileCpu), false, search, context);
166
- }
167
- /**
168
- * Remove the first matching entry from the specified database based on search criteria.
169
- */
170
- async removeOne({ collection, search, context = {} }) {
171
- await this.checkCollection(arguments[0]);
172
- return await operationUpdater(this._getCollectionPath(collection), this.fileCpu.remove.bind(this.fileCpu), true, search, context);
173
- }
174
- /**
175
- * Removes a database collection from the file system.
176
- */
177
- async removeCollection({ collection }) {
178
- await promises.rm(this.folder + "/" + collection, { recursive: true, force: true });
179
- return true;
180
- }
181
- /**
182
- * Apply a series of transactions to a database collection.
183
- */
184
- async transaction({ collection, transaction }) {
185
- await this.checkCollection(arguments[0]);
186
- const files = await getSortedFiles(this._getCollectionPath(collection));
187
- if (files.length == 0) {
188
- await promises.writeFile(this._getCollectionPath(collection) + "1.db", "");
189
- files.push("1.db");
190
- }
191
- for (const file of files) {
192
- await this.fileCpu.transactions(this._getCollectionPath(collection) + file, transaction);
193
- }
194
- console.log("Transactions applied successfully.");
195
- console.log("Files:", files);
196
- console.log("Transactions:", transaction);
197
- return true;
198
- }
199
- }
200
- /**
201
- * Get the last file in the specified directory.
202
- */
203
- async function getLastFile(path, maxFileSize = 1024 * 1024) {
204
- if (!existsSync(path))
205
- mkdirSync(path, { recursive: true });
206
- const files = await getSortedFiles(path);
207
- if (files.length == 0) {
208
- await promises.writeFile(path + "/1.db", "");
209
- return "1.db";
210
- }
211
- const last = files[files.length - 1];
212
- const info = path + "/" + last;
213
- if (statSync(info).size < maxFileSize)
214
- return last;
215
- const num = parseInt(last.replace(".db", ""), 10) + 1;
216
- await promises.writeFile(path + "/" + num + ".db", "");
217
- return num + ".db";
218
- }
219
- /**
220
- * Get all files in a directory sorted by name.
221
- */
222
- async function getSortedFiles(folder) {
223
- const files = await promises.readdir(folder, { withFileTypes: true });
224
- return files
225
- .filter(file => file.isFile() && !file.name.endsWith(".tmp"))
226
- .map(file => file.name)
227
- .filter(name => /^\d+\.db$/.test(name))
228
- .sort((a, b) => {
229
- const numA = parseInt(a, 10);
230
- const numB = parseInt(b, 10);
231
- return numA - numB;
232
- });
233
- }
234
- async function operationUpdater(cpath, worker, one, ...args) {
235
- const files = await getSortedFiles(cpath);
236
- let update = false;
237
- for (const file of files) {
238
- const updated = await worker(cpath + file, one, ...args);
239
- update = update || updated;
240
- if (one && updated)
241
- break;
242
- }
243
- return update;
244
- }
245
- export default dbActionC;
@@ -1,72 +0,0 @@
1
- import dbActionBase from "../base/actions.js";
2
- import Valthera from "../db/valthera.js";
3
- import Data from "../types/data.js";
4
- import FileCpu from "../types/fileCpu.js";
5
- import { DbOpts } from "../types/options.js";
6
- import { VQuery } from "../types/query.js";
7
- export declare class MemoryAction extends dbActionBase {
8
- folder: string;
9
- options: DbOpts;
10
- fileCpu: FileCpu;
11
- memory: Map<string, any[]>;
12
- /**
13
- * Creates a new instance of dbActionC.
14
- * @constructor
15
- * @param folder - The folder where database files are stored.
16
- * @param options - The options object.
17
- */
18
- constructor();
19
- _readMemory(key: string): any[];
20
- _writeMemory(key: string, data: any[]): void;
21
- _getCollectionPath(collection: string): string;
22
- /**
23
- * Get a list of available databases in the specified folder.
24
- */
25
- getCollections(): Promise<string[]>;
26
- /**
27
- * Check and create the specified collection if it doesn't exist.
28
- */
29
- checkCollection({ collection }: VQuery): Promise<boolean>;
30
- /**
31
- * Check if a collection exists.
32
- */
33
- issetCollection({ collection }: VQuery): Promise<boolean>;
34
- /**
35
- * Add a new entry to the specified database.
36
- */
37
- add({ collection, data, id_gen }: VQuery): Promise<import("../types/arg.js").Arg>;
38
- /**
39
- * Find entries in the specified database based on search criteria.
40
- */
41
- find({ collection, search, context, dbFindOpts, findOpts }: VQuery): Promise<Data[]>;
42
- /**
43
- * Find the first matching entry in the specified database based on search criteria.
44
- */
45
- findOne({ collection, search, context, findOpts }: VQuery): Promise<Data>;
46
- /**
47
- * Update entries in the specified database based on search criteria and an updater function or object.
48
- */
49
- update({ collection, search, updater, context }: VQuery): Promise<boolean>;
50
- /**
51
- * Update the first matching entry in the specified database based on search criteria and an updater function or object.
52
- */
53
- updateOne({ collection, search, updater, context }: VQuery): Promise<boolean>;
54
- /**
55
- * Remove entries from the specified database based on search criteria.
56
- */
57
- remove({ collection, search, context }: VQuery): Promise<boolean>;
58
- /**
59
- * Remove the first matching entry from the specified database based on search criteria.
60
- */
61
- removeOne({ collection, search, context }: VQuery): Promise<boolean>;
62
- /**
63
- * Removes a database collection from the file system.
64
- */
65
- removeCollection({ collection }: VQuery): Promise<boolean>;
66
- }
67
- export default class ValtheraMemory extends Valthera {
68
- constructor(...args: any[]);
69
- }
70
- export declare function createMemoryValthera<T = {
71
- [key: string]: Data[];
72
- }>(data?: T): ValtheraMemory;