@wxn0brp/db 0.3.2 → 0.3.3

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.
@@ -3,14 +3,13 @@ import { Search, Updater } from "../types/arg.js";
3
3
  import Data from "../types/data.js";
4
4
  import FileCpu from "../types/fileCpu.js";
5
5
  import { FindOpts } from "../types/options.js";
6
- type WriteFile = (file: string, data: any[]) => Promise<void>;
7
- type ReadFile = (file: string) => Promise<any[]>;
6
+ export type WriteFile = (file: string, data: any[]) => Promise<void>;
7
+ export type ReadFile = (file: string) => Promise<any[]>;
8
8
  declare class CustomFileCpu implements FileCpu {
9
9
  _readFile: ReadFile;
10
10
  _writeFile: WriteFile;
11
11
  constructor(readFile: ReadFile, writeFile: WriteFile);
12
12
  add(file: string, data: Data): Promise<void>;
13
- addMany(file: string, data: Data[]): Promise<void>;
14
13
  find(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any[] | false>;
15
14
  findOne(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any | false>;
16
15
  remove(file: string, one: boolean, arg: Search, context?: Context): Promise<boolean>;
@@ -14,17 +14,11 @@ class CustomFileCpu {
14
14
  entries.push(data);
15
15
  await this._writeFile(file, entries);
16
16
  }
17
- async addMany(file, data) {
18
- file = pathRepair(file);
19
- let entries = await this._readFile(file);
20
- entries = entries.concat(data);
21
- await this._writeFile(file, entries);
22
- }
23
17
  async find(file, arg, context = {}, findOpts = {}) {
24
18
  file = pathRepair(file);
25
19
  const entries = await this._readFile(file);
26
20
  const results = entries.filter(entry => typeof arg === "function" ? arg(entry, context) : hasFieldsAdvanced(entry, arg));
27
- return results.length ? results.map(res => updateFindObject(res, findOpts)) : false;
21
+ return results.length ? results.map(res => updateFindObject(res, findOpts)) : [];
28
22
  }
29
23
  async findOne(file, arg, context = {}, findOpts = {}) {
30
24
  file = pathRepair(file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "A simple file-based database management system with support for CRUD operations, custom queries, and graph structures.",