@wxn0brp/db 0.2.0 → 0.3.0

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 (125) hide show
  1. package/package.json +8 -11
  2. package/dist/cjs/CollectionManager.js +0 -59
  3. package/dist/cjs/action.js +0 -210
  4. package/dist/cjs/client/database.js +0 -119
  5. package/dist/cjs/client/function.js +0 -32
  6. package/dist/cjs/client/graph.js +0 -94
  7. package/dist/cjs/client/remote.js +0 -2
  8. package/dist/cjs/database.js +0 -113
  9. package/dist/cjs/executor.js +0 -47
  10. package/dist/cjs/file/customFileCpu.js +0 -79
  11. package/dist/cjs/file/find.js +0 -80
  12. package/dist/cjs/file/index.js +0 -21
  13. package/dist/cjs/file/remove.js +0 -46
  14. package/dist/cjs/file/update.js +0 -55
  15. package/dist/cjs/file/utils.js +0 -23
  16. package/dist/cjs/format.js +0 -30
  17. package/dist/cjs/gen.js +0 -137
  18. package/dist/cjs/graph.js +0 -90
  19. package/dist/cjs/index.js +0 -20
  20. package/dist/cjs/relation.js +0 -64
  21. package/dist/cjs/types/Id.js +0 -2
  22. package/dist/cjs/types/arg.js +0 -2
  23. package/dist/cjs/types/data.js +0 -2
  24. package/dist/cjs/types/fileCpu.js +0 -2
  25. package/dist/cjs/types/options.js +0 -2
  26. package/dist/cjs/types/searchOpts.js +0 -8
  27. package/dist/cjs/types/types.js +0 -2
  28. package/dist/cjs/types/updater.js +0 -5
  29. package/dist/cjs/utils/hasFields.js +0 -21
  30. package/dist/cjs/utils/hasFieldsAdvanced.js +0 -182
  31. package/dist/cjs/utils/updateFindObject.js +0 -31
  32. package/dist/cjs/utils/updateObject.js +0 -148
  33. package/dist/esm/CollectionManager.d.ts +0 -44
  34. package/dist/esm/action.d.ts +0 -68
  35. package/dist/esm/client/database.d.ts +0 -72
  36. package/dist/esm/client/function.d.ts +0 -5
  37. package/dist/esm/client/graph.d.ts +0 -54
  38. package/dist/esm/client/remote.d.ts +0 -15
  39. package/dist/esm/database.d.ts +0 -70
  40. package/dist/esm/executor.d.ts +0 -28
  41. package/dist/esm/file/customFileCpu.d.ts +0 -19
  42. package/dist/esm/file/find.d.ts +0 -11
  43. package/dist/esm/file/index.d.ts +0 -3
  44. package/dist/esm/file/remove.d.ts +0 -7
  45. package/dist/esm/file/update.d.ts +0 -7
  46. package/dist/esm/file/utils.d.ts +0 -8
  47. package/dist/esm/format.d.ts +0 -12
  48. package/dist/esm/gen.d.ts +0 -8
  49. package/dist/esm/graph.d.ts +0 -47
  50. package/dist/esm/index.d.ts +0 -14
  51. package/dist/esm/relation.d.ts +0 -34
  52. package/dist/esm/types/Id.d.ts +0 -3
  53. package/dist/esm/types/arg.d.ts +0 -12
  54. package/dist/esm/types/data.d.ts +0 -4
  55. package/dist/esm/types/fileCpu.d.ts +0 -51
  56. package/dist/esm/types/options.d.ts +0 -12
  57. package/dist/esm/types/searchOpts.d.ts +0 -62
  58. package/dist/esm/types/types.d.ts +0 -3
  59. package/dist/esm/types/updater.d.ts +0 -26
  60. package/dist/esm/utils/hasFields.d.ts +0 -7
  61. package/dist/esm/utils/hasFieldsAdvanced.d.ts +0 -5
  62. package/dist/esm/utils/updateFindObject.d.ts +0 -11
  63. package/dist/esm/utils/updateObject.d.ts +0 -7
  64. /package/dist/{cjs/CollectionManager.d.ts → CollectionManager.d.ts} +0 -0
  65. /package/dist/{esm/CollectionManager.js → CollectionManager.js} +0 -0
  66. /package/dist/{cjs/action.d.ts → action.d.ts} +0 -0
  67. /package/dist/{esm/action.js → action.js} +0 -0
  68. /package/dist/{cjs/client → client}/database.d.ts +0 -0
  69. /package/dist/{esm/client → client}/database.js +0 -0
  70. /package/dist/{cjs/client → client}/function.d.ts +0 -0
  71. /package/dist/{esm/client → client}/function.js +0 -0
  72. /package/dist/{cjs/client → client}/graph.d.ts +0 -0
  73. /package/dist/{esm/client → client}/graph.js +0 -0
  74. /package/dist/{cjs/client → client}/remote.d.ts +0 -0
  75. /package/dist/{esm/client → client}/remote.js +0 -0
  76. /package/dist/{cjs/database.d.ts → database.d.ts} +0 -0
  77. /package/dist/{esm/database.js → database.js} +0 -0
  78. /package/dist/{cjs/executor.d.ts → executor.d.ts} +0 -0
  79. /package/dist/{esm/executor.js → executor.js} +0 -0
  80. /package/dist/{cjs/file → file}/customFileCpu.d.ts +0 -0
  81. /package/dist/{esm/file → file}/customFileCpu.js +0 -0
  82. /package/dist/{cjs/file → file}/find.d.ts +0 -0
  83. /package/dist/{esm/file → file}/find.js +0 -0
  84. /package/dist/{cjs/file → file}/index.d.ts +0 -0
  85. /package/dist/{esm/file → file}/index.js +0 -0
  86. /package/dist/{cjs/file → file}/remove.d.ts +0 -0
  87. /package/dist/{esm/file → file}/remove.js +0 -0
  88. /package/dist/{cjs/file → file}/update.d.ts +0 -0
  89. /package/dist/{esm/file → file}/update.js +0 -0
  90. /package/dist/{cjs/file → file}/utils.d.ts +0 -0
  91. /package/dist/{esm/file → file}/utils.js +0 -0
  92. /package/dist/{cjs/format.d.ts → format.d.ts} +0 -0
  93. /package/dist/{esm/format.js → format.js} +0 -0
  94. /package/dist/{cjs/gen.d.ts → gen.d.ts} +0 -0
  95. /package/dist/{esm/gen.js → gen.js} +0 -0
  96. /package/dist/{cjs/graph.d.ts → graph.d.ts} +0 -0
  97. /package/dist/{esm/graph.js → graph.js} +0 -0
  98. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  99. /package/dist/{esm/index.js → index.js} +0 -0
  100. /package/dist/{cjs/relation.d.ts → relation.d.ts} +0 -0
  101. /package/dist/{esm/relation.js → relation.js} +0 -0
  102. /package/dist/{cjs/types → types}/Id.d.ts +0 -0
  103. /package/dist/{esm/types → types}/Id.js +0 -0
  104. /package/dist/{cjs/types → types}/arg.d.ts +0 -0
  105. /package/dist/{esm/types → types}/arg.js +0 -0
  106. /package/dist/{cjs/types → types}/data.d.ts +0 -0
  107. /package/dist/{esm/types → types}/data.js +0 -0
  108. /package/dist/{cjs/types → types}/fileCpu.d.ts +0 -0
  109. /package/dist/{esm/types → types}/fileCpu.js +0 -0
  110. /package/dist/{cjs/types → types}/options.d.ts +0 -0
  111. /package/dist/{esm/types → types}/options.js +0 -0
  112. /package/dist/{cjs/types → types}/searchOpts.d.ts +0 -0
  113. /package/dist/{esm/types → types}/searchOpts.js +0 -0
  114. /package/dist/{cjs/types → types}/types.d.ts +0 -0
  115. /package/dist/{esm/types → types}/types.js +0 -0
  116. /package/dist/{cjs/types → types}/updater.d.ts +0 -0
  117. /package/dist/{esm/types → types}/updater.js +0 -0
  118. /package/dist/{cjs/utils → utils}/hasFields.d.ts +0 -0
  119. /package/dist/{esm/utils → utils}/hasFields.js +0 -0
  120. /package/dist/{cjs/utils → utils}/hasFieldsAdvanced.d.ts +0 -0
  121. /package/dist/{esm/utils → utils}/hasFieldsAdvanced.js +0 -0
  122. /package/dist/{cjs/utils → utils}/updateFindObject.d.ts +0 -0
  123. /package/dist/{esm/utils → utils}/updateFindObject.js +0 -0
  124. /package/dist/{cjs/utils → utils}/updateObject.d.ts +0 -0
  125. /package/dist/{esm/utils → utils}/updateObject.js +0 -0
@@ -1,54 +0,0 @@
1
- import { Remote } from "./remote.js";
2
- /**
3
- * A class representing a graph database.
4
- * Uses a remote database.
5
- * @class
6
- */
7
- declare class GraphRemote {
8
- remote: Remote;
9
- /**
10
- * Create a new database instance.
11
- */
12
- constructor(remote: Remote);
13
- /**
14
- * Make a request to the remote database.
15
- */
16
- _request(type: string, params?: any[]): Promise<any>;
17
- /**
18
- * Adds an edge between two nodes.
19
- */
20
- add(collection: string, nodeA: string, nodeB: string): Promise<any>;
21
- /**
22
- * Removes an edge between two nodes.
23
- */
24
- remove(collection: string, nodeA: string, nodeB: string): Promise<any>;
25
- /**
26
- * Finds all edges with either node equal to `node`.
27
- */
28
- find(collection: string, node: string): Promise<any>;
29
- /**
30
- * Finds one edge with either node equal to `nodeA` and the other equal to `nodeB`.
31
- */
32
- findOne(collection: string, nodeA: string, nodeB: string): Promise<any>;
33
- /**
34
- * Get all edges in the collection.
35
- */
36
- getAll(collection: string): Promise<any>;
37
- /**
38
- * Get the names of all available databases.
39
- */
40
- getCollections(): Promise<any>;
41
- /**
42
- * Check and create the specified collection if it doesn't exist.
43
- */
44
- checkCollection(collection: string): Promise<any>;
45
- /**
46
- * Check if a collection exists.
47
- */
48
- issetCollection(collection: string): Promise<any>;
49
- /**
50
- * Remove the specified collection.
51
- */
52
- removeCollection(collection: string): Promise<any>;
53
- }
54
- export default GraphRemote;
@@ -1,15 +0,0 @@
1
- export interface Remote {
2
- name: string;
3
- url: string;
4
- auth: string;
5
- }
6
- export interface RequestData {
7
- db?: string;
8
- keys?: string[];
9
- params?: Record<string, any>;
10
- }
11
- export interface findOptsRemote {
12
- select?: string[];
13
- exclude?: string[];
14
- transform?: string;
15
- }
@@ -1,70 +0,0 @@
1
- import dbActionC from "./action.js";
2
- import executorC from "./executor.js";
3
- import CollectionManager from "./CollectionManager.js";
4
- import { DbFindOpts, DbOpts, FindOpts } from "./types/options.js";
5
- import { Arg, Search, Updater } from "./types/arg.js";
6
- import Data from "./types/data.js";
7
- import { Context } from "./types/types.js";
8
- import FileCpu from "./types/fileCpu.js";
9
- /**
10
- * Represents a database management class for performing CRUD operations.
11
- * @class
12
- */
13
- declare class DataBase {
14
- dbAction: dbActionC;
15
- executor: executorC;
16
- constructor(folder: string, options?: DbOpts, fileCpu?: FileCpu);
17
- /**
18
- * Create a new instance of a CollectionManager class.
19
- */
20
- c(collection: string): CollectionManager;
21
- /**
22
- * Get the names of all available databases.
23
- */
24
- getCollections(): Promise<string[]>;
25
- /**
26
- * Check and create the specified collection if it doesn't exist.
27
- */
28
- checkCollection(collection: string): Promise<void>;
29
- /**
30
- * Check if a collection exists.
31
- */
32
- issetCollection(collection: string): Promise<boolean>;
33
- /**
34
- * Add data to a database.
35
- */
36
- add<T = Data>(collection: string, data: Arg, id_gen?: boolean): Promise<T>;
37
- /**
38
- * Find data in a database.
39
- */
40
- find<T = Data>(collection: string, search: Search, context?: Context, options?: DbFindOpts, findOpts?: FindOpts): Promise<T[]>;
41
- /**
42
- * Find one data entry in a database.
43
- */
44
- findOne<T = Data>(collection: string, search: Search, context?: Context, findOpts?: FindOpts): Promise<T>;
45
- /**
46
- * Update data in a database.
47
- */
48
- update(collection: string, search: Search, updater: Updater, context?: {}): Promise<boolean>;
49
- /**
50
- * Update one data entry in a database.
51
- */
52
- updateOne(collection: string, search: Search, updater: Updater, context?: Context): Promise<boolean>;
53
- /**
54
- * Remove data from a database.
55
- */
56
- remove(collection: string, search: Search, context?: Context): Promise<boolean>;
57
- /**
58
- * Remove one data entry from a database.
59
- */
60
- removeOne(collection: string, search: Search, context?: Context): Promise<boolean>;
61
- /**
62
- * Asynchronously updates one entry in a database or adds a new one if it doesn't exist.
63
- */
64
- updateOneOrAdd(collection: string, search: Search, updater: Updater, add_arg?: Arg, context?: Context, id_gen?: boolean): Promise<boolean>;
65
- /**
66
- * Removes a database collection from the file system.
67
- */
68
- removeCollection(collection: string): Promise<void>;
69
- }
70
- export default DataBase;
@@ -1,28 +0,0 @@
1
- interface Task {
2
- func: Function;
3
- param: any[];
4
- resolve: Function;
5
- reject: Function;
6
- }
7
- /**
8
- * A simple executor for queuing and executing asynchronous operations sequentially.
9
- * @class
10
- */
11
- declare class executorC {
12
- quote: Task[];
13
- isExecuting: boolean;
14
- /**
15
- * Create a new executor instance.
16
- * @constructor
17
- */
18
- constructor();
19
- /**
20
- * Add an asynchronous operation to the execution queue.
21
- */
22
- addOp(func: Function, ...param: any[]): Promise<unknown>;
23
- /**
24
- * Execute the queued asynchronous operations sequentially.
25
- */
26
- execute(): Promise<void>;
27
- }
28
- export default executorC;
@@ -1,19 +0,0 @@
1
- import { Context } from "vm";
2
- import { Search, Updater } from "../types/arg.js";
3
- import Data from "../types/data.js";
4
- import FileCpu from "../types/fileCpu.js";
5
- import { FindOpts } from "../types/options.js";
6
- type WriteFile = (file: string, data: any[]) => Promise<void>;
7
- type ReadFile = (file: string) => Promise<any[]>;
8
- declare class CustomFileCpu implements FileCpu {
9
- _readFile: ReadFile;
10
- _writeFile: WriteFile;
11
- constructor(readFile: ReadFile, writeFile: WriteFile);
12
- add(file: string, data: Data): Promise<void>;
13
- addMany(file: string, data: Data[]): Promise<void>;
14
- find(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any[] | false>;
15
- findOne(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any | false>;
16
- remove(file: string, one: boolean, arg: Search, context?: Context): Promise<boolean>;
17
- update(file: string, one: boolean, arg: Search, updater: Updater, context?: Context): Promise<boolean>;
18
- }
19
- export default CustomFileCpu;
@@ -1,11 +0,0 @@
1
- import { Search } from "../types/arg.js";
2
- import { Context } from "../types/types.js";
3
- import { FindOpts } from "../types/options.js";
4
- /**
5
- * Asynchronously finds entries in a file based on search criteria.
6
- */
7
- export declare function find(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any[] | false>;
8
- /**
9
- * Asynchronously finds one entry in a file based on search criteria.
10
- */
11
- export declare function findOne(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any | false>;
@@ -1,3 +0,0 @@
1
- import FileCpu from "../types/fileCpu.js";
2
- declare const vFileCpu: FileCpu;
3
- export default vFileCpu;
@@ -1,7 +0,0 @@
1
- import { Search } from "../types/arg.js";
2
- import { Context } from "../types/types.js";
3
- /**
4
- * Removes entries from a file based on search criteria.
5
- */
6
- declare function removeWorker(file: string, one: boolean, search: Search, context?: Context): Promise<boolean>;
7
- export default removeWorker;
@@ -1,7 +0,0 @@
1
- import { Context } from "../types/types.js";
2
- import { Search, Updater } from "../types/arg.js";
3
- /**
4
- * Updates a file based on search criteria and an updater function or object.
5
- */
6
- declare function updateWorker(file: string, one: boolean, search: Search, updater: Updater, context?: Context): Promise<boolean>;
7
- export default updateWorker;
@@ -1,8 +0,0 @@
1
- /**
2
- * Repairs a file path by replacing double slashes
3
- */
4
- export declare function pathRepair(path: string): string;
5
- /**
6
- * Creates a Readline interface for reading large files with a specified high water mark.
7
- */
8
- export declare function createRL(file: string): import("readline").Interface;
@@ -1,12 +0,0 @@
1
- /**
2
- * Parses given string into a JSON object. If the string does not start with
3
- * a {, it is wrapped in one. This allows for a shorthand when
4
- * storing/reading data from a file.
5
- */
6
- export declare function parse(data: string): any;
7
- /**
8
- * Converts given object to a string. If the string is a valid json5, it is
9
- * returned as is. If it is a valid json5 wrapped in {}, the curly brackets
10
- * are removed. Otherwise the string is wrapped in {}.
11
- */
12
- export declare function stringify(data: any): any;
package/dist/esm/gen.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import Id from "./types/Id.js";
2
- /**
3
- * Generates a unique random identifier based on time and parts.
4
- *
5
- * @param {number[]} [parts] - an array of lengths of parts of the identifier
6
- * @returns {Id} - a new unique identifier
7
- */
8
- export default function genId(parts?: number[]): Id;
@@ -1,47 +0,0 @@
1
- import DataBase from "./database.js";
2
- import Data from "./types/data.js";
3
- /**
4
- * A class representing a graph database.
5
- * @class
6
- */
7
- declare class Graph {
8
- db: DataBase;
9
- constructor(databaseFolder: string);
10
- /**
11
- * Adds an edge between two nodes.
12
- */
13
- add(collection: string, nodeA: string, nodeB: string): Promise<Data>;
14
- /**
15
- * Removes an edge between two nodes.
16
- */
17
- remove(collection: string, nodeA: string, nodeB: string): Promise<boolean>;
18
- /**
19
- * Finds all edges with either node equal to `node`.
20
- */
21
- find(collection: string, node: string): Promise<Data[]>;
22
- /**
23
- * Finds one edge with either node equal to `nodeA` and the other equal to `nodeB`.
24
- */
25
- findOne(collection: any, nodeA: any, nodeB: any): Promise<Data>;
26
- /**
27
- * Gets all edges in the database.
28
- */
29
- getAll(collection: any): Promise<Data[]>;
30
- /**
31
- * Get the names of all available databases.
32
- */
33
- getCollections(): Promise<string[]>;
34
- /**
35
- * Check and create the specified collection if it doesn't exist.
36
- */
37
- checkCollection(collection: any): Promise<void>;
38
- /**
39
- * Check if a collection exists.
40
- */
41
- issetCollection(collection: any): Promise<boolean>;
42
- /**
43
- * Removes a database collection from the file system.
44
- */
45
- removeCollection(collection: any): void;
46
- }
47
- export default Graph;
@@ -1,14 +0,0 @@
1
- import DataBase from "./database.js";
2
- import Graph from "./graph.js";
3
- import DataBaseRemote from "./client/database.js";
4
- import GraphRemote from "./client/graph.js";
5
- import genId from "./gen.js";
6
- import Relation from "./relation.js";
7
- import CustomFileCpu from "./file/customFileCpu.js";
8
- export { DataBase, Graph, DataBaseRemote, GraphRemote, Relation, genId, CustomFileCpu, };
9
- import type Id from "./types/Id.js";
10
- import type { Arg, Search, Updater } from "./types/arg.js";
11
- import type { DbFindOpts, FindOpts, DbOpts } from "./types/options.js";
12
- import type Data from "./types/data.js";
13
- import type { SearchOptions } from "./types/searchOpts.js";
14
- export type { Id, Arg, Search, Updater, DbFindOpts, FindOpts, DbOpts, Data, SearchOptions, };
@@ -1,34 +0,0 @@
1
- import DataBase from "./database.js";
2
- import { Search } from "./types/arg.js";
3
- import { DbFindOpts } from "./types/options.js";
4
- export interface Databases {
5
- [key: string]: DataBase;
6
- }
7
- interface RelationConfig {
8
- from: string;
9
- localField: string;
10
- foreignField: string;
11
- as?: string;
12
- multiple?: boolean;
13
- }
14
- declare class Relation {
15
- private databases;
16
- constructor(databases: Databases);
17
- /**
18
- * Resolves the relation path in format 'dbName.collectionName'.
19
- */
20
- private _resolvePath;
21
- /**
22
- * Processes relations for a single item.
23
- */
24
- private _processItemRelations;
25
- /**
26
- * Finds multiple items with relations.
27
- */
28
- find(path: string, search: Search, relations?: Record<string, RelationConfig>, options?: DbFindOpts): Promise<Record<string, any>[]>;
29
- /**
30
- * Finds a single item with relations.
31
- */
32
- findOne(path: string, search: Search, relations?: Record<string, RelationConfig>): Promise<Record<string, any> | null>;
33
- }
34
- export default Relation;
@@ -1,3 +0,0 @@
1
- type Id = string;
2
- export default Id;
3
- export { Id };
@@ -1,12 +0,0 @@
1
- import Id from "./Id.js";
2
- import { SearchOptions } from "./searchOpts.js";
3
- import { Context } from "./types.js";
4
- import { UpdaterArg } from "./updater.js";
5
- export interface Arg {
6
- _id?: Id;
7
- [key: string]: any;
8
- }
9
- export type SearchFunc<T = any> = (data: T, context: Context) => boolean;
10
- export type UpdaterFunc<T = any> = (data: T, context: Context) => boolean;
11
- export type Search<T = any> = SearchOptions | SearchFunc<T>;
12
- export type Updater<T = any> = UpdaterArg | UpdaterArg[] | UpdaterFunc<T>;
@@ -1,4 +0,0 @@
1
- export interface Data {
2
- [key: string]: any;
3
- }
4
- export default Data;
@@ -1,51 +0,0 @@
1
- import { Search, Updater } from "./arg.js";
2
- import Data from "./data.js";
3
- import { FindOpts } from "./options.js";
4
- import { Context } from "./types.js";
5
- interface FileCpu {
6
- /**
7
- * Asynchronously adds an entry to a file.
8
- * @param file The path to the file.
9
- * @param data The data to add.
10
- * @returns A promise resolving to `void`.
11
- */
12
- add(file: string, data: Data): Promise<void>;
13
- /**
14
- * Asynchronously finds multiple entries in a file based on search criteria.
15
- * @param file The path to the file.
16
- * @param arg The search criteria.
17
- * @param context Additional context for the search.
18
- * @param findOpts Additional options for searching.
19
- * @returns A promise resolving to an array of found entries, or `false` if the file does not exist.
20
- */
21
- find(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any[] | false>;
22
- /**
23
- * Asynchronously finds one entry in a file based on search criteria.
24
- * @param file The path to the file.
25
- * @param arg The search criteria.
26
- * @param context Additional context for the search.
27
- * @param findOpts Additional options for searching.
28
- * @returns A promise resolving to the found entry or `false` if not found.
29
- */
30
- findOne(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any | false>;
31
- /**
32
- * Asynchronously removes entries from a file based on search criteria.
33
- * @param file The path to the file.
34
- * @param arg The search criteria.
35
- * @param context Additional context for the operation.
36
- * @param one If `true`, removes only the first matching entry.
37
- * @returns A promise resolving to `true` if at least one entry was removed, otherwise `false`.
38
- */
39
- remove(file: string, one: boolean, arg: Search, context?: Context): Promise<boolean>;
40
- /**
41
- * Asynchronously updates entries in a file based on search criteria and an updater function or object.
42
- * @param file The path to the file.
43
- * @param arg The search criteria.
44
- * @param updater The updater function or object.
45
- * @param context Additional context for the operation.
46
- * @param one If `true`, updates only the first matching entry.
47
- * @returns A promise resolving to `true` if at least one entry was updated, otherwise `false`.
48
- */
49
- update(file: string, one: boolean, arg: Search, updater: Updater, context?: Context): Promise<boolean>;
50
- }
51
- export default FileCpu;
@@ -1,12 +0,0 @@
1
- export interface DbOpts {
2
- maxFileSize?: number;
3
- }
4
- export interface DbFindOpts {
5
- reverse?: boolean;
6
- max?: number;
7
- }
8
- export interface FindOpts {
9
- select?: string[];
10
- exclude?: string[];
11
- transform?: Function;
12
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * Predefined Search Options Quick Reference
3
- *
4
- * This module defines the types and structures for search operators used
5
- * to validate and query data objects.
6
- */
7
- import { Arg } from "./arg.js";
8
- /** Logical Operators */
9
- export type LogicalOperators = {
10
- /**
11
- * Recursively applies multiple conditions, all of which must evaluate to true.
12
- * Can include other operators such as $gt, $exists, or nested $and/$or conditions.
13
- */
14
- $and?: Array<SearchOptions>;
15
- /**
16
- * Recursively applies multiple conditions, at least one of which must evaluate to true.
17
- * Can include other operators such as $lt, $type, or nested $and/$or conditions.
18
- */
19
- $or?: Array<SearchOptions>;
20
- /**
21
- * Negates a single condition.
22
- * Can include any other operator as its value.
23
- */
24
- $not?: SearchOptions;
25
- };
26
- /** Comparison Operators */
27
- export type ComparisonOperators = {
28
- $gt?: Record<string, number>;
29
- $lt?: Record<string, number>;
30
- $gte?: Record<string, number>;
31
- $lte?: Record<string, number>;
32
- $in?: Record<string, any[]>;
33
- $nin?: Record<string, any[]>;
34
- $between?: Record<string, [number, number]>;
35
- };
36
- /** Type and Existence Operators */
37
- export type TypeAndExistenceOperators = {
38
- $exists?: Record<string, boolean>;
39
- $type?: Record<string, string>;
40
- };
41
- /** Array Operators */
42
- export type ArrayOperators = {
43
- $arrinc?: Record<string, any[]>;
44
- $arrincall?: Record<string, any[]>;
45
- $size?: Record<string, number>;
46
- };
47
- /** String Operators */
48
- export type StringOperators = {
49
- $regex?: Record<string, RegExp>;
50
- $startsWith?: Record<string, string>;
51
- $endsWith?: Record<string, string>;
52
- };
53
- /** Other Operators */
54
- export type OtherOperators = {
55
- $subset?: Record<string, any>;
56
- };
57
- /** Predefined Search Operators */
58
- export type PredefinedSearchOperators = LogicalOperators & ComparisonOperators & TypeAndExistenceOperators & ArrayOperators & StringOperators & OtherOperators;
59
- /**
60
- * SearchOptions can be either a function or an object with predefined operators.
61
- */
62
- export type SearchOptions = PredefinedSearchOperators & Arg;
@@ -1,3 +0,0 @@
1
- export interface Context {
2
- [key: string]: any;
3
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * Predefined type for updating data.
3
- */
4
- /** Arrays */
5
- export type ArrayUpdater = {
6
- $push?: any;
7
- /** Pushes items into an array and removes duplicates */
8
- $pushset?: any;
9
- $pull?: any;
10
- $pullall?: any;
11
- };
12
- /** Objects */
13
- export type ObjectUpdater = {
14
- $merge?: any;
15
- };
16
- /** Values */
17
- export type ValueUpdater = {
18
- $set?: any;
19
- $inc?: any;
20
- $dec?: any;
21
- $unset?: any;
22
- $rename?: any;
23
- };
24
- export type UpdaterArg = ArrayUpdater & ObjectUpdater & ValueUpdater & {
25
- [key: string]: any;
26
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * Checks if an object matches the standard field comparison.
3
- * @param obj - The object to check.
4
- * @param fields - Criteria to compare.
5
- * @returns Whether the object matches the criteria.
6
- */
7
- export default function hasFields(obj: Object, fields: Object): boolean;
@@ -1,5 +0,0 @@
1
- import { Arg } from "../types/arg.js";
2
- /**
3
- * Checks if an object meets the criteria specified in the fields with operators.
4
- */
5
- export default function hasFieldsAdvanced(obj: Object, fields: Arg): any;
@@ -1,11 +0,0 @@
1
- import { FindOpts } from "../types/options.js";
2
- /**
3
- * Updates an object with new values from a findOpts object.
4
- * @param obj - The object to update.
5
- * @param findOpts - An object containing options to update the target object.
6
- * @param [findOpts.transform] - A function to transform the object before applying the other options.
7
- * @param [findOpts.select] - An array of fields to select from the target object.
8
- * @param [findOpts.exclude] - An array of fields to exclude from the target object.
9
- * @returns The updated object.
10
- */
11
- export default function updateFindObject(obj: Object, findOpts: FindOpts): Object;
@@ -1,7 +0,0 @@
1
- import { UpdaterArg } from "../types/updater.js";
2
- /**
3
- * Updates an object with new values.
4
- * @param obj - The object to update.
5
- * @param fields - An object containing new values to update in the target object.
6
- */
7
- export default function updateObjectAdvanced(obj: Object, fields: UpdaterArg | UpdaterArg[]): Object;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes