@wxn0brp/db-storage-dir 0.2.0 → 0.2.2

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
@@ -6,4 +6,4 @@ This plugin provides directory-based operations for ValtheraDB.
6
6
 
7
7
  ```bash
8
8
  npm install @wxn0brp/db-storage-dir
9
- ```
9
+ ```
package/dist/action.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { ActionsBase } from "@wxn0brp/db-core/base/actions";
2
2
  import { Data } from "@wxn0brp/db-core/types/data";
3
3
  import { FileCpu } from "@wxn0brp/db-core/types/fileCpu";
4
- import { DbOpts } from "@wxn0brp/db-core/types/options";
5
4
  import { VQuery } from "@wxn0brp/db-core/types/query";
6
5
  import { FileActionsUtils } from "./action.utils.js";
6
+ import { DbDirOpts } from "./types.js";
7
7
  /**
8
8
  * A class representing database actions on files.
9
9
  * @class
@@ -12,7 +12,7 @@ export declare class FileActions extends ActionsBase {
12
12
  fileCpu: FileCpu;
13
13
  utils: FileActionsUtils;
14
14
  folder: string;
15
- options: DbOpts;
15
+ options: DbDirOpts;
16
16
  _inited: boolean;
17
17
  /**
18
18
  * Creates a new instance of FileActions.
@@ -22,7 +22,7 @@ export declare class FileActions extends ActionsBase {
22
22
  * @param fileCpu - The file cpu instance
23
23
  * @param utils - The utils instance
24
24
  */
25
- constructor(folder: string, options: DbOpts, fileCpu: FileCpu, utils?: FileActionsUtils);
25
+ constructor(folder: string, options: DbDirOpts, fileCpu: FileCpu, utils?: FileActionsUtils);
26
26
  init(): Promise<void>;
27
27
  _getCollectionPath(collection: string): string;
28
28
  /**
@@ -56,7 +56,7 @@ export declare class FileActions extends ActionsBase {
56
56
  /**
57
57
  * Update the first matching entry in the specified database based on search criteria and an updater function or object.
58
58
  */
59
- updateOne(query: VQuery): Promise<any[]>;
59
+ updateOne(query: VQuery): Promise<any>;
60
60
  /**
61
61
  * Remove entries from the specified database based on search criteria.
62
62
  */
@@ -64,7 +64,7 @@ export declare class FileActions extends ActionsBase {
64
64
  /**
65
65
  * Remove the first matching entry from the specified database based on search criteria.
66
66
  */
67
- removeOne(query: VQuery): Promise<any[]>;
67
+ removeOne(query: VQuery): Promise<any>;
68
68
  /**
69
69
  * Removes a database collection from the file system.
70
70
  */
package/dist/action.js CHANGED
@@ -132,7 +132,8 @@ export class FileActions extends ActionsBase {
132
132
  async updateOne(query) {
133
133
  const { collection, search, updater, context = {} } = query;
134
134
  await this.ensureCollection(query);
135
- return await this.utils.operationUpdater(this._getCollectionPath(collection), this.fileCpu.update.bind(this.fileCpu), true, query, search, updater, context);
135
+ const res = await this.utils.operationUpdater(this._getCollectionPath(collection), this.fileCpu.update.bind(this.fileCpu), true, query, search, updater, context);
136
+ return res[0];
136
137
  }
137
138
  /**
138
139
  * Remove entries from the specified database based on search criteria.
@@ -148,7 +149,8 @@ export class FileActions extends ActionsBase {
148
149
  async removeOne(query) {
149
150
  const { collection, search, context = {} } = query;
150
151
  await this.ensureCollection(query);
151
- return await this.utils.operationUpdater(this._getCollectionPath(collection), this.fileCpu.remove.bind(this.fileCpu), true, query, search, context);
152
+ const res = await this.utils.operationUpdater(this._getCollectionPath(collection), this.fileCpu.remove.bind(this.fileCpu), true, query, search, context);
153
+ return res[0];
152
154
  }
153
155
  /**
154
156
  * Removes a database collection from the file system.
@@ -1,8 +1,8 @@
1
- import { update } from "./update.js";
2
- import { remove } from "./remove.js";
3
- import { find, findOne } from "./find.js";
4
1
  import { appendFileSync } from "fs";
5
2
  import { stringifyData } from "../format.js";
3
+ import { find, findOne } from "./find.js";
4
+ import { remove } from "./remove.js";
5
+ import { update } from "./update.js";
6
6
  export const vFileCpu = {
7
7
  add: async (file, data) => {
8
8
  const dataString = stringifyData(data);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { DbOpts } from "@wxn0brp/db-core/types/options";
2
1
  import { FileActions } from "./action.js";
2
+ import { DbDirOpts } from "./types.js";
3
3
  export * from "./file/index.js";
4
4
  export * from "./action.js";
5
- export declare function createFileActions(folder: string, options?: DbOpts): FileActions;
5
+ export declare function createFileActions(folder: string, options?: DbDirOpts): FileActions;
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { DbOpts } from "@wxn0brp/db-core/types/options";
1
2
  declare module "@wxn0brp/db-core/types/query" {
2
3
  interface VQuery_Control {
3
4
  dir: {
@@ -6,4 +7,6 @@ declare module "@wxn0brp/db-core/types/query" {
6
7
  };
7
8
  }
8
9
  }
9
- export {};
10
+ export type DbDirOpts = Omit<DbOpts, "dbAction"> & {
11
+ maxFileSize?: number;
12
+ };
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "0.2.0";
1
+ export const version = "0.2.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db-storage-dir",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",
@@ -21,11 +21,11 @@
21
21
  "json5": "^2.2.3"
22
22
  },
23
23
  "peerDependencies": {
24
- "@wxn0brp/db-core": "~0.5.0"
24
+ "@wxn0brp/db-core": "~0.7.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/bun": "*",
28
- "@wxn0brp/db-core": "~0.5.0",
28
+ "@wxn0brp/db-core": "~0.7.0",
29
29
  "tsc-alias": "*",
30
30
  "typescript": "*"
31
31
  },