@wxn0brp/db 0.0.1 → 0.0.4

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 CHANGED
@@ -1,194 +1,30 @@
1
- # DataBase Class
1
+ # @wxn0brp/db
2
2
 
3
- The `DataBase` class simplifies managing data with a file-based database, providing an easy way to perform CRUD operations, caching, and custom queries.
3
+ A lightweight file-based database management system that supports CRUD operations, custom queries, and graph structures.
4
4
 
5
5
  ## Installation
6
6
 
7
- Ensure you have Node.js installed. To install the `DataBase` package, run:
7
+ To install the package, run:
8
8
 
9
9
  ```bash
10
- npm install @wxn0brp/database
10
+ npm install @wxn0brp/db
11
11
  ```
12
12
 
13
- ## Usage Example
13
+ ## Usage
14
14
 
15
- ```javascript
16
- import DataBase from '@wxn0brp/database/database.js';
17
-
18
- async function main(){
19
- // Initialize the database with a folder path and optional cache settings
20
- const db = new DataBase('./data');
21
-
22
- // Create or check a collection
23
- await db.checkCollection('users');
24
-
25
- // Add a new user to the collection
26
- await db.add('users', { name: 'Alice', age: 30 });
27
-
28
- // Find users based on search criteria
29
- const users = await db.find('users', { age: 30 });
30
- console.log(users);
31
-
32
- // Update a user's data
33
- await db.update('users', { name: 'Alice' }, { age: 31 });
34
-
35
- // Remove a user
36
- await db.remove('users', { name: 'Alice' });
37
- }
38
-
39
- main().catch(console.error);
40
-
41
- ```
42
-
43
- ## Methods Overview
44
-
45
- | Method Name | Description | Parameters | Returns |
46
- | ----------- | ----------- | ---------- | ------- |
47
- | `getCollections` | Retrieves the names of all available collections. | None | `string[]` |
48
- | `checkCollection` | Ensures that a collection exists, creating it if necessary. | `collection` (string): Name of the collection | `Promise<void>` |
49
- | `issetCollection` | Checks if a collection exists. | `collection` (string): Name of the collection | `Promise<boolean>` |
50
- | `add` | Adds data to a collection, optionally generating an ID. | `collection` (string), `data` (Object), `id_gen` (boolean) | `Promise<Object>` |
51
- | `find` | Finds data entries matching a query. | `collection` (string), `search` (function/Object), `context` (Object), `options` (Object) - { max, reverse } | `Promise<Array<Object>>` |
52
- | `findOne` | Finds the first data entry matching a query. | `collection` (string), `search` (function/Object), `context` (Object) | `Promise<Object\|null>` |
53
- | `update` | Updates data entries matching a query. | `collection` (string), `search` (function/Object), `arg` (function/Object), `context` (Object) | `Promise<boolean>` |
54
- | `updateOne` | Updates the first data entry matching a query. | `collection` (string), `search` (function/Object), `arg` (function/Object), `context` (Object) | `Promise<boolean>` |
55
- | `remove` | Removes data entries matching a query. | `collection` (string), `search` (function/Object), `context` (Object) | `Promise<boolean>` |
56
- | `removeOne` | Removes the first data entry matching a query. | `collection` (string), `search` (function/Object), `context` (Object) | `Promise<boolean>` |
57
- | `updateOneOrAdd` | Updates one entry or adds a new one if no match is found. | `collection` (string), `search` (function/Object), `arg` (function/Object), `add_arg` (function/Object), `context` (Object), `id_gen` (boolean) | `Promise<boolean>` |
58
- | `removeDb` | Removes an entire database collection from the file system. | `collection` (string) | `void` |
59
-
60
- ---
61
-
62
- ### Querying Data
63
-
64
- The `DataBase` class offers flexibility for querying collections using either an object or a function as the `search` parameter in methods like `find`, `findOne`, `update`, and `remove`.
65
-
66
- #### Object-Based Queries
67
-
68
- You can use the following operators to build your queries:
69
-
70
- - **`$or`**: Matches if at least one condition is true.
71
-
72
- ```javascript
73
- const result = await db.find('users', {
74
- $or: [{ status: 'active' }, { role: 'admin' }]
75
- });
76
- ```
77
-
78
- - **`$not`**: Matches if the condition is false.
79
-
80
- ```javascript
81
- const result = await db.find('users', {
82
- $not: { status: 'inactive' }
83
- });
84
- ```
85
-
86
- - **`$and`**: Combines multiple conditions, all of which must be true. Useful for complex queries involving other operators.
87
-
88
- ```javascript
89
- const result = await db.find('users', {
90
- $and: [
91
- { age: 25 },
92
- { $or: [{ status: 'active' }, { status: 'away' }] }
93
- ]
94
- });
95
- ```
96
-
97
- - **`$set`**: Ensures that specified fields are present in the document.
98
-
99
- ```javascript
100
- const result = await db.find('users', {
101
- $set: { name: true }
102
- });
103
- ```
104
-
105
- #### Search as a Function
106
-
107
- Alternatively, you can use a function for more dynamic queries. The function receives each document as an argument and should return `true` for documents that match the criteria.
108
-
109
- ```javascript
110
- const results = await db.find('users', obj => obj.age > 30);
111
- ```
112
-
113
- This approach is powerful for cases where the query logic is too complex to be represented as an object.
114
-
115
- ### Update Argument
116
-
117
- When updating data, the `update` argument can also be either an object or a function.
118
-
119
- #### Update as an Object
120
-
121
- If you pass an object as the `update` argument, it will directly set the new values for the specified fields.
122
-
123
- ##### Example: Update with Object
15
+ You can import the necessary classes from the package as follows:
124
16
 
125
17
  ```javascript
126
- // Updates the age of all users named 'Alice' to 31
127
- await db.update('users', { name: 'Alice' }, { age: 31 });
18
+ import { DataBase, Graph, DataBaseRemote, GraphRemote, Relation, genId } from "@wxn0brp/db";
128
19
  ```
129
20
 
130
- #### Update as a Function
131
-
132
- If you pass a function, it receives the current object as an argument and should return the updated object. This allows for dynamic updates based on the current state of the object.
133
-
134
- ##### Example: Update with Function
135
-
136
- ```javascript
137
- // Increments the age of all users named 'Alice' by 1
138
- await db.update('users', { name: 'Alice' }, obj => {
139
- obj.age++;
140
- return obj;
141
- });
142
- ```
143
-
144
- This method is useful when you need to compute new values based on existing ones.
145
-
146
- ## Other Features
147
-
148
- ### Graph.js
149
-
150
- The `Graph` class extends the functionality of the `DataBase` class to handle graph-like structures, where relationships (edges) between nodes (vertices) are stored in collections.
151
-
152
- #### Methods
153
-
154
- - **`add(collection, a, b)`**: Adds an edge between `a` and `b` in the specified collection. The nodes are sorted to ensure consistency in the storage format.
155
-
156
- ```javascript
157
- // Adds a friendship between Alice and Bob
158
- await graph.add('friends', 'Alice', 'Bob');
159
- ```
160
-
161
- - **`remove(collection, a, b)`**: Removes the edge between `a` and `b`.
162
-
163
- ```javascript
164
- // Removes the friendship between Alice and Bob
165
- await graph.remove('friends', 'Alice', 'Bob');
166
- ```
167
-
168
- - **`find(collection, d)`**: Finds all edges where `d` is one of the nodes.
169
-
170
- ```javascript
171
- // Returns all friends of Alice
172
- const friends = await graph.find('friends', 'Alice');
173
- ```
174
-
175
- - **`findOne(collection, d, e)`**: Finds the edge between `d` and `e`.
176
-
177
- ```javascript
178
- // Returns the friendship between Alice and Bob, if it exists
179
- const relation = await graph.findOne('friends', 'Alice', 'Bob');
180
- ```
181
-
182
- ### Gen.js
183
-
184
- The `gen.js` file contains a utility function `genId`, which generates a unique identifier.
185
-
186
- #### Example: Generating an ID
187
-
188
- ```javascript
189
- const id = genId();
190
- ```
21
+ ## Documentation
191
22
 
192
- ## License
23
+ For detailed information, refer to the following resources:
193
24
 
194
- This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). See the [LICENSE](./LICENSE) file for details.
25
+ - [DataBase Documentation](./docs/database.md)
26
+ - [Graph Documentation](./docs/graph.md)
27
+ - [Remote Database and Graph Client Documentation](./docs/remote.md)
28
+ - [Remote Server Documentation](./docs/remote_server.md)
29
+ - [Search Options Documentation](./docs/search_opts.md)
30
+ - [Relation Documentation](./docs/relation.md)
package/action.js CHANGED
@@ -3,8 +3,6 @@ import gen from "./gen.js";
3
3
  import { stringify } from "./format.js";
4
4
  import { find as _find, findOne as _findOne, update as _update, remove as _remove } from "./file/index.js";
5
5
 
6
- const maxFileSize = 2 * 1024 * 1024; //2 MB
7
-
8
6
  /**
9
7
  * A class representing database actions on files.
10
8
  * @class
@@ -18,11 +16,18 @@ class dbActionC{
18
16
  */
19
17
  constructor(folder, options){
20
18
  this.folder = folder;
21
- // this.cacheManager = new CacheManager(options.cacheThreshold, options.cacheTTL);
19
+ this.options = {
20
+ maxFileSize: 2 * 1024 * 1024, //2 MB
21
+ ...options,
22
+ };
22
23
 
23
24
  if(!existsSync(folder)) mkdirSync(folder, { recursive: true });
24
25
  }
25
26
 
27
+ _getCollectionPath(collection){
28
+ return this.folder + "/" + collection + "/";
29
+ }
30
+
26
31
  /**
27
32
  * Get a list of available databases in the specified folder.
28
33
  * @returns {string[]} An array of database names.
@@ -44,8 +49,8 @@ class dbActionC{
44
49
  * @param {string} collection - The collection to check.
45
50
  */
46
51
  checkCollection(collection){
47
- const path = this.folder + "/" + collection;
48
- if(!existsSync(path)) mkdirSync(path, { recursive: true });
52
+ const cpath = this._getCollectionPath(collection);
53
+ if(!existsSync(cpath)) mkdirSync(cpath, { recursive: true });
49
54
  }
50
55
 
51
56
  /**
@@ -69,7 +74,8 @@ class dbActionC{
69
74
  */
70
75
  async add(collection, arg, id_gen=true){
71
76
  await this.checkCollection(collection);
72
- const file = this.folder + "/" + collection + "/" + getLastFile(this.folder + "/" + collection);
77
+ const cpath = this._getCollectionPath(collection);
78
+ const file = cpath + getLastFile(cpath, this.options.maxFileSize);
73
79
 
74
80
  if(id_gen) arg._id = arg._id || gen();
75
81
  const data = stringify(arg);
@@ -94,14 +100,15 @@ class dbActionC{
94
100
  options.max = options.max || -1;
95
101
 
96
102
  await this.checkCollection(collection);
97
- const files = getSortedFiles(this.folder + "/" + collection).map(f => f.f);
103
+ const cpath = this._getCollectionPath(collection);
104
+ const files = getSortedFiles(cpath).map(f => f.f);
98
105
  if(options.reverse) files.reverse();
99
106
  let datas = [];
100
107
 
101
108
  let totalEntries = 0;
102
109
 
103
110
  for(let f of files){
104
- let data = await _find(this.folder + "/" + collection + "/" + f, arg, context, findOpts);
111
+ let data = await _find(cpath + f, arg, context, findOpts);
105
112
  if(options.reverse) data.reverse();
106
113
 
107
114
  if(options.max !== -1){
@@ -132,11 +139,11 @@ class dbActionC{
132
139
  */
133
140
  async findOne(collection, arg, context={}, findOpts={}){
134
141
  await this.checkCollection(collection);
135
- const files = getSortedFiles(this.folder + "/" + collection).map(f => f.f);
136
- files.reverse();
142
+ const cpath = this._getCollectionPath(collection);
143
+ const files = getSortedFiles(cpath).map(f => f.f);
137
144
 
138
145
  for(let f of files){
139
- let data = await _findOne(this.folder + "/" + collection + "/" + f, arg, context, findOpts);
146
+ let data = await _findOne(cpath + f, arg, context, findOpts);
140
147
  if(data){
141
148
  return data;
142
149
  }
@@ -155,7 +162,7 @@ class dbActionC{
155
162
  */
156
163
  async update(collection, arg, obj, context={}){
157
164
  await this.checkCollection(collection);
158
- return await _update(this.folder, collection, arg, obj, context);
165
+ return await _update(this._getCollectionPath(collection), arg, obj, context);
159
166
  }
160
167
 
161
168
  /**
@@ -169,7 +176,7 @@ class dbActionC{
169
176
  */
170
177
  async updateOne(collection, arg, obj, context={}){
171
178
  await this.checkCollection(collection);
172
- return await _update(this.folder, collection, arg, obj, context, true);
179
+ return await _update(this._getCollectionPath(collection), arg, obj, context, true);
173
180
  }
174
181
 
175
182
  /**
@@ -182,7 +189,7 @@ class dbActionC{
182
189
  */
183
190
  async remove(collection, arg, context={}){
184
191
  await this.checkCollection(collection);
185
- return await _remove(this.folder, collection, arg, context);
192
+ return await _remove(this._getCollectionPath(collection), arg, context);
186
193
  }
187
194
 
188
195
  /**
@@ -195,7 +202,7 @@ class dbActionC{
195
202
  */
196
203
  async removeOne(collection, arg, context={}){
197
204
  await this.checkCollection(collection);
198
- return await _remove(this.folder, collection, arg, context, true);
205
+ return await _remove(this._getCollectionPath(collection), arg, context, true);
199
206
  }
200
207
 
201
208
  /**
@@ -204,7 +211,7 @@ class dbActionC{
204
211
  * @param {string} collection - The name of the collection to remove.
205
212
  * @return {void}
206
213
  */
207
- removeDb(collection){
214
+ removeCollection(collection){
208
215
  rmSync(this.folder + "/" + collection, { recursive: true, force: true });
209
216
  }
210
217
  }
@@ -212,9 +219,10 @@ class dbActionC{
212
219
  /**
213
220
  * Get the last file in the specified directory.
214
221
  * @param {string} path - The directory path.
222
+ * @param {number} maxFileSize - The maximum file size in bytes. Default is 1 MB.
215
223
  * @returns {string} The name of the last file in the directory.
216
224
  */
217
- function getLastFile(path){
225
+ function getLastFile(path, maxFileSize=1024*1024){
218
226
  if(!existsSync(path)) mkdirSync(path, { recursive: true });
219
227
  const files = getSortedFiles(path);
220
228
 
package/database.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ import dbActionC from "./action.js";
2
+ import executorC from "./executor.js";
3
+ import CollectionManager from "./CollectionManager.js";
4
+
5
+ declare class DataBase {
6
+ constructor(folder: string, options?: {
7
+ cacheThreshold?: number,
8
+ cacheTTL?: number
9
+ });
10
+
11
+ dbAction: dbActionC;
12
+ executor: executorC;
13
+
14
+ c(collection: string): CollectionManager;
15
+
16
+ getCollections(): Promise<string[]>;
17
+
18
+ checkCollection(collection: string): Promise<void>;
19
+
20
+ issetCollection(collection: string): Promise<boolean>;
21
+
22
+ add(collection: string, data: object, id_gen?: boolean): Promise<object>;
23
+
24
+ find(collection: string, search: object | Function, context?: object, options?: {
25
+ max?: number,
26
+ reverse?: boolean
27
+ }, findOpts?: object): Promise<object[]>;
28
+
29
+ findOne(collection: string, search: object | Function, context?: object, findOpts?: object): Promise<object | null>;
30
+
31
+ update(collection: string, search: object | Function, arg: object | Function, context?: object): Promise<boolean>;
32
+
33
+ updateOne(collection: string, search: object | Function, arg: object | Function, context?: object): Promise<boolean>;
34
+
35
+ remove(collection: string, search: object | Function, context?: object): Promise<boolean>;
36
+
37
+ removeOne(collection: string, search: object | Function, context?: object): Promise<boolean>;
38
+
39
+ updateOneOrAdd(collection: string, search: object | Function, arg: object | Function, add_arg?: object, context?: object, id_gen?: boolean): Promise<boolean>;
40
+
41
+ removeCollection(collection: string): void;
42
+ }
43
+
44
+ export default DataBase;
package/database.js CHANGED
@@ -12,15 +12,10 @@ class DataBase{
12
12
  * @constructor
13
13
  * @param {string} folder - The folder path where the database files are stored.
14
14
  * @param {object} [options] - The options object.
15
- * @param {number} [options.cacheThreshold=3] - The cache threshold for database entries (default: 3).
16
- * @param {number} [options.cacheTTL=300000] - The time-to-live (TTL) for cached entries in milliseconds (default: 300,000 milliseconds or 5 minutes).
15
+ * @param {number} [options.maxFileSize=2*1024*1024] - The maximum size of a file in bytes. Default is 2 MB.
16
+ * @param {number}
17
17
  */
18
18
  constructor(folder, options={}){
19
- options = {
20
- cacheThreshold: 3,
21
- cacheTTL: 300_000,
22
- ...options
23
- }
24
19
  this.dbAction = new dbActionC(folder, options);
25
20
  this.executor = new executorC();
26
21
  }
@@ -200,8 +195,8 @@ class DataBase{
200
195
  * @param {string} collection - The name of the collection to remove.
201
196
  * @return {void}
202
197
  */
203
- removeDb(collection){
204
- this.dbAction.removeDb(collection);
198
+ removeCollection(collection){
199
+ this.dbAction.removeCollection(collection);
205
200
  }
206
201
  }
207
202
 
@@ -0,0 +1,140 @@
1
+ # DataBase Class Documentation
2
+
3
+ This documentation provides a detailed overview of the `DataBase` class, designed for performing CRUD operations on database collections. The class uses the `dbActionC` module for file-based operations and `executorC` for managing execution tasks.
4
+
5
+ ## Class: `DataBase`
6
+
7
+ ### Constructor: `DataBase(folder, options={})`
8
+ Creates a new instance of the `DataBase` class.
9
+
10
+ - **Parameters:**
11
+ - `folder` (`string`): The folder path where the database files are stored.
12
+ - `options` (`object`): Optional configuration options.
13
+ - `cacheThreshold` (`number`, default: 3): The threshold for caching entries.
14
+ - `cacheTTL` (`number`, default: 300000): Time-to-live for cache entries in milliseconds (default: 5 minutes).
15
+
16
+ ### Method: `c(collection)`
17
+ Creates a new instance of the `CollectionManager` class for the specified collection.
18
+
19
+ - **Parameters:**
20
+ - `collection` (`string`): The name of the collection.
21
+ - **Returns:**
22
+ - `CollectionManager`: A new instance of `CollectionManager`.
23
+
24
+ ### Method: `async getCollections()`
25
+ Gets the names of all available collections in the database.
26
+
27
+ - **Returns:**
28
+ - `Promise<string[]>`: A promise that resolves with an array of collection names.
29
+
30
+ ### Method: `async checkCollection(collection)`
31
+ Checks and creates the specified collection if it doesn't exist.
32
+
33
+ - **Parameters:**
34
+ - `collection` (`string`): The name of the collection to check.
35
+
36
+ ### Method: `async issetCollection(collection)`
37
+ Checks if a collection exists.
38
+
39
+ - **Parameters:**
40
+ - `collection` (`string`): The name of the collection.
41
+ - **Returns:**
42
+ - `Promise<boolean>`: A promise that resolves to `true` if the collection exists, otherwise `false`.
43
+
44
+ ### Method: `async add(collection, data, id_gen=true)`
45
+ Adds data to a specified collection.
46
+
47
+ - **Parameters:**
48
+ - `collection` (`string`): The name of the collection.
49
+ - `data` (`Object`): The data to add.
50
+ - `id_gen` (`boolean`, default: true): Whether to generate an ID for the entry.
51
+ - **Returns:**
52
+ - `Promise<Object>`: A promise that resolves with the added data.
53
+
54
+ ### Method: `async find(collection, search, context={}, options={}, findOpts={})`
55
+ Finds data in a collection based on a query.
56
+
57
+ - **Parameters:**
58
+ - `collection` (`string`): The name of the collection.
59
+ - `search` (`function|Object`): The search query.
60
+ - `context` (`Object`): The context object (for functions).
61
+ - `options` (`Object`): Search options.
62
+ - `max` (`number`, default: -1): Maximum number of entries to return.
63
+ - `reverse` (`boolean`, default: false): Whether to reverse the search results.
64
+ - `findOpts` (`Object`): Options for updating the search result.
65
+ - **Returns:**
66
+ - `Promise<Array<Object>>`: A promise that resolves with the matching data.
67
+
68
+ ### Method: `async findOne(collection, search, context={}, findOpts={})`
69
+ Finds one matching entry in a collection.
70
+
71
+ - **Parameters:**
72
+ - `collection` (`string`): The name of the collection.
73
+ - `search` (`function|Object`): The search query.
74
+ - `context` (`Object`): The context object (for functions).
75
+ - `findOpts` (`Object`): Options for updating the search result.
76
+ - **Returns:**
77
+ - `Promise<Object|null>`: A promise that resolves with the found entry, or `null` if no match is found.
78
+
79
+ ### Method: `async update(collection, search, arg, context={})`
80
+ Updates data in a collection.
81
+
82
+ - **Parameters:**
83
+ - `collection` (`string`): The name of the collection.
84
+ - `search` (`function|Object`): The search query.
85
+ - `arg` (`function|Object`): Update arguments.
86
+ - `context` (`Object`): The context object (for functions).
87
+ - **Returns:**
88
+ - `Promise<boolean>`: A promise that resolves when the data is updated.
89
+
90
+ ### Method: `async updateOne(collection, search, arg, context={})`
91
+ Updates one entry in a collection.
92
+
93
+ - **Parameters:**
94
+ - `collection` (`string`): The name of the collection.
95
+ - `search` (`function|Object`): The search query.
96
+ - `arg` (`function|Object`): Update arguments.
97
+ - `context` (`Object`): The context object (for functions).
98
+ - **Returns:**
99
+ - `Promise<boolean>`: A promise that resolves when the data is updated.
100
+
101
+ ### Method: `async updateOneOrAdd(collection, search, arg, add_arg={}, context={}, id_gen=true)`
102
+ Updates one entry or adds a new one if it doesn't exist.
103
+
104
+ - **Parameters:**
105
+ - `collection` (`string`): The name of the collection.
106
+ - `search` (`function|Object`): The search query.
107
+ - `arg` (`function|Object`): Update arguments.
108
+ - `add_arg` (`function|Object`): Data to add if no match is found.
109
+ - `context` (`Object`): The context object (for functions).
110
+ - `id_gen` (`boolean`, default: true): Whether to generate an ID for the new entry.
111
+ - **Returns:**
112
+ - `Promise<boolean>`: A promise that resolves to `true` if the entry was updated, otherwise `false`.
113
+
114
+ ### Method: `async remove(collection, search, context={})`
115
+ Removes data from a collection.
116
+
117
+ - **Parameters:**
118
+ - `collection` (`string`): The name of the collection.
119
+ - `search` (`function|Object`): The search query.
120
+ - `context` (`Object`): The context object (for functions).
121
+ - **Returns:**
122
+ - `Promise<boolean>`: A promise that resolves when the data is removed.
123
+
124
+ ### Method: `async removeOne(collection, search, context={})`
125
+ Removes one entry from a collection.
126
+
127
+ - **Parameters:**
128
+ - `collection` (`string`): The name of the collection.
129
+ - `search` (`function|Object`): The search query.
130
+ - `context` (`Object`): The context object (for functions).
131
+ - **Returns:**
132
+ - `Promise<boolean>`: A promise that resolves when the entry is removed.
133
+
134
+ ### Method: `removeCollection(collection)`
135
+ Removes the specified collection from the database file system.
136
+
137
+ - **Parameters:**
138
+ - `collection` (`string`): The name of the collection to remove.
139
+ - **Returns:**
140
+ - `void`
package/docs/graph.md ADDED
@@ -0,0 +1,86 @@
1
+ # Graph Database Documentation
2
+
3
+ This documentation provides an overview of the `Graph` class, which represents a graph database built on top of a custom `DataBase` module. The `Graph` class allows for managing graph structures by adding, removing, and querying edges between nodes in the database.
4
+
5
+ ## Class: `Graph`
6
+
7
+ ### Constructor: `Graph(databaseFolder)`
8
+ Initializes the graph database.
9
+
10
+ - **Parameters:**
11
+ - `databaseFolder` (`string`): The folder where the database is stored.
12
+
13
+ ### Method: `async add(collection, nodeA, nodeB)`
14
+ Adds an edge between two nodes in the specified collection.
15
+
16
+ - **Parameters:**
17
+ - `collection` (`string`): The name of the collection.
18
+ - `nodeA` (`string`): The first node.
19
+ - `nodeB` (`string`): The second node.
20
+ - **Returns:**
21
+ - `Promise<Object>`: A promise that resolves with the added edge.
22
+
23
+ ### Method: `async remove(collection, nodeA, nodeB)`
24
+ Removes an edge between two nodes in the specified collection.
25
+
26
+ - **Parameters:**
27
+ - `collection` (`string`): The name of the collection.
28
+ - `nodeA` (`string`): The first node.
29
+ - `nodeB` (`string`): The second node.
30
+ - **Returns:**
31
+ - `Promise<boolean>`: A promise that resolves to `true` if the edge is removed, otherwise `false`.
32
+
33
+ ### Method: `async find(collection, node)`
34
+ Finds all edges with either node equal to the specified `node`.
35
+
36
+ - **Parameters:**
37
+ - `collection` (`string`): The name of the collection.
38
+ - `node` (`string`): The node to search for.
39
+ - **Returns:**
40
+ - `Promise<Object[]>`: A promise that resolves with an array of edges.
41
+
42
+ ### Method: `async findOne(collection, nodeA, nodeB)`
43
+ Finds one edge with either `nodeA` or `nodeB` as nodes.
44
+
45
+ - **Parameters:**
46
+ - `collection` (`string`): The name of the collection.
47
+ - `nodeA` (`string`): The first node.
48
+ - `nodeB` (`string`): The second node.
49
+ - **Returns:**
50
+ - `Promise<Object|null>`: A promise that resolves with the found edge or `null` if no edge is found.
51
+
52
+ ### Method: `async getAll(collection)`
53
+ Gets all edges in the specified collection.
54
+
55
+ - **Parameters:**
56
+ - `collection` (`string`): The name of the collection.
57
+ - **Returns:**
58
+ - `Promise<Object[]>`: A promise that resolves with all edges in the collection.
59
+
60
+ ### Method: `async getCollections()`
61
+ Returns the names of all available collections in the database.
62
+
63
+ - **Returns:**
64
+ - `Promise<string[]>`: A promise that resolves with an array of collection names.
65
+
66
+ ### Method: `async checkCollection(collection)`
67
+ Checks and creates the specified collection if it doesn't exist.
68
+
69
+ - **Parameters:**
70
+ - `collection` (`string`): The name of the collection.
71
+
72
+ ### Method: `async issetCollection(collection)`
73
+ Checks if the specified collection exists.
74
+
75
+ - **Parameters:**
76
+ - `collection` (`string`): The name of the collection.
77
+ - **Returns:**
78
+ - `Promise<boolean>`: A promise that resolves to `true` if the collection exists, otherwise `false`.
79
+
80
+ ### Method: `removeCollection(collection)`
81
+ Removes the specified collection from the database file system.
82
+
83
+ - **Parameters:**
84
+ - `collection` (`string`): The name of the collection to remove.
85
+ - **Returns:**
86
+ - `void`