@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
@@ -1,155 +0,0 @@
1
- function pickByPath(obj, paths) {
2
- const result = {};
3
- for (const path of paths) {
4
- let src = obj;
5
- let dst = result;
6
- for (let i = 0; i < path.length; i++) {
7
- const k = path[i];
8
- if (src == null)
9
- break;
10
- if (i === path.length - 1) {
11
- dst[k] = src[k];
12
- }
13
- else {
14
- dst[k] ||= {};
15
- dst = dst[k];
16
- src = src[k];
17
- }
18
- }
19
- }
20
- return result;
21
- }
22
- function autoSelect(rel, key) {
23
- const select = Array.isArray(rel.select) ? [...rel.select] : undefined;
24
- const shouldDelete = select && !select.includes(key);
25
- if (shouldDelete)
26
- select.push(key);
27
- return [select, shouldDelete];
28
- }
29
- function convertSearchObjToSearchArray(obj, parentKeys = []) {
30
- return Object.entries(obj).reduce((acc, [key, value]) => {
31
- const currentPath = [...parentKeys, key];
32
- if (!value) {
33
- return acc;
34
- }
35
- else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
36
- return [...acc, ...convertSearchObjToSearchArray(value, currentPath)];
37
- }
38
- else {
39
- return [...acc, currentPath];
40
- }
41
- }, []);
42
- }
43
- async function processRelations(dbs, cfg, data, parentList = null) {
44
- if (!data && !parentList)
45
- return;
46
- const batchMode = Array.isArray(parentList);
47
- const targets = batchMode ? parentList : [data];
48
- for (const key in cfg) {
49
- if (!cfg.hasOwnProperty(key))
50
- continue;
51
- const rel = cfg[key];
52
- const { pk = "_id", fk = "_id", type = "1", path, as = key, select, findOpts = {}, through } = rel;
53
- const [dbKey, coll] = path;
54
- const db = dbs[dbKey];
55
- if (type === "1") {
56
- const keys = [...new Set(targets.map(i => i[pk]))];
57
- const [selectSafe, deleteSelect] = autoSelect(rel, fk);
58
- const results = await db.find(coll, { $in: { [fk]: keys } }, {}, {}, { select: selectSafe });
59
- const map = new Map(results.map(row => [row[fk], row]));
60
- for (const item of targets) {
61
- const result = map.get(item[pk]) || null;
62
- if (result && rel.relations) {
63
- await processRelations(dbs, rel.relations, result);
64
- }
65
- if (deleteSelect && result)
66
- delete result[fk];
67
- item[as] = result;
68
- }
69
- }
70
- else if (type === "11") {
71
- const cache = new Map();
72
- const [selectSafe, deleteSelect] = autoSelect(rel, fk);
73
- for (const item of targets) {
74
- const id = item[pk];
75
- if (!cache.has(id)) {
76
- cache.set(id, await db.findOne(coll, { [fk]: id }, {}, { select: selectSafe }));
77
- }
78
- const result = cache.get(id) || null;
79
- if (result && rel.relations) {
80
- await processRelations(dbs, rel.relations, result);
81
- }
82
- if (deleteSelect && result)
83
- delete result[fk];
84
- item[as] = result;
85
- }
86
- }
87
- else if (type === "1n") {
88
- const ids = targets.map(i => i[pk]);
89
- const [selectSafe, deleteSelect] = autoSelect(rel, fk);
90
- const results = await db.find(coll, { $in: { [fk]: ids } }, {}, findOpts || {}, { select: selectSafe });
91
- const grouped = results.reduce((acc, row) => {
92
- const id = row[fk];
93
- (acc[id] ||= []).push(row);
94
- return acc;
95
- }, {});
96
- for (const item of targets) {
97
- item[as] = grouped[item[pk]] || [];
98
- }
99
- if (rel.relations) {
100
- await Promise.all(results.map(row => processRelations(dbs, rel.relations, row)));
101
- }
102
- if (deleteSelect)
103
- for (const r of results)
104
- delete r[fk];
105
- }
106
- else if (type === "nm") {
107
- if (!through || !through.table || !through.pk || !through.fk) {
108
- throw new Error(`Relation type "nm" requires a defined 'through' in '${key}'`);
109
- }
110
- for (const item of targets) {
111
- const pivotDb = dbs[through.db || dbKey];
112
- const pivots = await pivotDb.find(through.table, { [through.pk]: item[pk] });
113
- const ids = pivots.map(p => p[through.fk]);
114
- const related = await db.find(coll, { $in: { [fk]: ids } }, {}, {}, { select });
115
- item[as] = related;
116
- if (rel.relations) {
117
- await Promise.all(related.map(row => processRelations(dbs, rel.relations, row)));
118
- }
119
- }
120
- }
121
- else {
122
- throw new Error(`Unknown relation type: ${type}`);
123
- }
124
- }
125
- }
126
- class Relation {
127
- dbs;
128
- constructor(dbs) {
129
- this.dbs = dbs;
130
- }
131
- async findOne(path, search, relations, select) {
132
- const [dbKey, coll] = path;
133
- const db = this.dbs[dbKey];
134
- const data = await db.findOne(coll, search);
135
- if (!data)
136
- return null;
137
- if (typeof select === "object" && !Array.isArray(select)) {
138
- select = convertSearchObjToSearchArray(select);
139
- }
140
- await processRelations(this.dbs, relations, data);
141
- return select ? pickByPath(data, select) : data;
142
- }
143
- async find(path, search, relations, select, findOpts = {}) {
144
- const [dbKey, coll] = path;
145
- const db = this.dbs[dbKey];
146
- const data = await db.find(coll, search, {}, findOpts);
147
- if (relations)
148
- await processRelations(this.dbs, relations, null, data);
149
- if (typeof select === "object" && !Array.isArray(select)) {
150
- select = convertSearchObjToSearchArray(select);
151
- }
152
- return select ? data.map(d => pickByPath(d, select)) : data;
153
- }
154
- }
155
- export default Relation;
@@ -1,2 +0,0 @@
1
- import { VQuery } from "../types/query.js";
2
- export declare function setDataUsingUpdateOneOrAdd(query: VQuery): void;
@@ -1,18 +0,0 @@
1
- function assignDataPush(data) {
2
- if (typeof data !== "object" || Array.isArray(data))
3
- return;
4
- const obj = {};
5
- for (const key of Object.keys(data)) {
6
- if (key.startsWith("$")) {
7
- Object.keys(data[key]).forEach((k) => {
8
- obj[k] = data[key][k];
9
- });
10
- }
11
- else
12
- obj[key] = data[key];
13
- }
14
- return obj;
15
- }
16
- export function setDataUsingUpdateOneOrAdd(query) {
17
- query.data = Object.assign({}, assignDataPush(query.search), assignDataPush(query.updater), assignDataPush(query.add_arg));
18
- }
@@ -1,3 +0,0 @@
1
- type Id = string;
2
- export default Id;
3
- export { Id };
package/dist/types/Id.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -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>;
package/dist/types/arg.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export interface Data {
2
- [key: string]: any;
3
- }
4
- export default Data;
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- export declare namespace ValtheraTypes {
2
- type Arg = import("./arg.js").Arg;
3
- type Search = import("./arg.js").Search;
4
- type Updater = import("./arg.js").Updater;
5
- type DbFindOpts = import("./options.js").DbFindOpts;
6
- type FindOpts = import("./options.js").FindOpts;
7
- type DbOpts = import("./options.js").DbOpts;
8
- type Data = import("./data.js").Data;
9
- type SearchOptions = import("./searchOpts.js").SearchOptions;
10
- type Id = import("./Id.js").Id;
11
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,69 +0,0 @@
1
- import { Search, Updater } from "./arg.js";
2
- import Data from "./data.js";
3
- import { FindOpts } from "./options.js";
4
- import { Transaction } from "./transactions.js";
5
- import { Context } from "./types.js";
6
- interface FileCpu {
7
- /**
8
- * Asynchronously adds an entry to a file.
9
- * @param file The path to the file.
10
- * @param data The data to add.
11
- * @returns A promise resolving to `void`.
12
- */
13
- add(file: string, data: Data): Promise<void>;
14
- /**
15
- * Asynchronously finds multiple entries in a file based on search criteria.
16
- * @param file The path to the file.
17
- * @param arg The search criteria.
18
- * @param context Additional context for the search.
19
- * @param findOpts Additional options for searching.
20
- * @returns A promise resolving to an array of found entries, or `false` if the file does not exist.
21
- */
22
- find(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any[] | false>;
23
- /**
24
- * Asynchronously finds one entry in a file based on search criteria.
25
- * @param file The path to the file.
26
- * @param arg The search criteria.
27
- * @param context Additional context for the search.
28
- * @param findOpts Additional options for searching.
29
- * @returns A promise resolving to the found entry or `false` if not found.
30
- */
31
- findOne(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any | false>;
32
- /**
33
- * Asynchronously finds entries in a file based on search criteria and returns a stream of results.
34
- * @param file The path to the file.
35
- * @param arg The search criteria.
36
- * @param context Additional context for the search.
37
- * @param findOpts Additional options for searching.
38
- * @param limit The maximum number of entries to return.
39
- * @returns An async generator yielding found entries.
40
- */
41
- findStream(file: string, arg: Search, context?: Context, findOpts?: FindOpts, limit?: number): AsyncGenerator<any>;
42
- /**
43
- * Asynchronously removes entries from a file based on search criteria.
44
- * @param file The path to the file.
45
- * @param arg The search criteria.
46
- * @param context Additional context for the operation.
47
- * @param one If `true`, removes only the first matching entry.
48
- * @returns A promise resolving to `true` if at least one entry was removed, otherwise `false`.
49
- */
50
- remove(file: string, one: boolean, arg: Search, context?: Context): Promise<boolean>;
51
- /**
52
- * Asynchronously updates entries in a file based on search criteria and an updater function or object.
53
- * @param file The path to the file.
54
- * @param arg The search criteria.
55
- * @param updater The updater function or object.
56
- * @param context Additional context for the operation.
57
- * @param one If `true`, updates only the first matching entry.
58
- * @returns A promise resolving to `true` if at least one entry was updated, otherwise `false`.
59
- */
60
- update(file: string, one: boolean, arg: Search, updater: Updater, context?: Context): Promise<boolean>;
61
- /**
62
- * Executes a list of transactions on the specified database collection.
63
- * @param file The path to the file.
64
- * @param transactions An array of transactions to execute.
65
- * @returns A promise resolved when all transactions have been executed.
66
- */
67
- transactions(file: string, transactions: Transaction[]): Promise<void>;
68
- }
69
- export default FileCpu;
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- import dbActionC from "../actions/action.js";
2
- import executorC from "../helpers/executor.js";
3
- export interface DbOpts {
4
- maxFileSize?: number;
5
- dbAction?: dbActionC;
6
- executor?: executorC;
7
- }
8
- export interface DbFindOpts {
9
- reverse?: boolean;
10
- max?: number;
11
- }
12
- export interface FindOpts {
13
- select?: string[];
14
- exclude?: string[];
15
- transform?: Function;
16
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- import { Context } from "./types.js";
2
- import { Arg, Search, Updater } from "./arg.js";
3
- import { DbFindOpts, FindOpts } from "./options.js";
4
- import { Transaction } from "./transactions.js";
5
- export interface VQuery {
6
- collection?: string;
7
- search?: Search;
8
- context?: Context;
9
- dbFindOpts?: DbFindOpts;
10
- findOpts?: FindOpts;
11
- data?: Arg;
12
- id_gen?: boolean;
13
- limit?: number;
14
- add_arg?: Arg;
15
- updater?: Updater;
16
- transaction?: Transaction[];
17
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,28 +0,0 @@
1
- import { DbFindOpts } from "./options.js";
2
- import { ValtheraCompatible } from "./valthera.js";
3
- export declare namespace RelationTypes {
4
- type Path = [string, string];
5
- type FieldPath = string[];
6
- interface DBS {
7
- [key: string]: ValtheraCompatible;
8
- }
9
- interface Relation {
10
- [key: string]: RelationConfig;
11
- }
12
- interface RelationConfig {
13
- path: Path;
14
- pk?: string;
15
- fk?: string;
16
- as?: string;
17
- select?: string[];
18
- findOpts?: DbFindOpts;
19
- type?: "1" | "11" | "1n" | "nm";
20
- relations?: Relation;
21
- through?: {
22
- table: string;
23
- db?: string;
24
- pk: string;
25
- fk: string;
26
- };
27
- }
28
- }
@@ -1 +0,0 @@
1
- export {};
@@ -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,7 +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
- export {};
@@ -1,10 +0,0 @@
1
- import { Arg, Search, Updater } from "./arg.js";
2
- import { Context } from "./types.js";
3
- export interface Transaction {
4
- type: 'update' | 'updateOne' | 'updateOneOrAdd' | 'remove' | 'removeOne';
5
- search: Search;
6
- updater?: Updater;
7
- addArg?: Arg;
8
- idGen?: boolean;
9
- context?: Context;
10
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export interface Context {
2
- [key: string]: any;
3
- }
@@ -1 +0,0 @@
1
- export {};
@@ -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,4 +0,0 @@
1
- /**
2
- * Predefined type for updating data.
3
- */
4
- export {};
@@ -1,41 +0,0 @@
1
- import CollectionManager from "../helpers/CollectionManager.js";
2
- import { Arg, Search, Updater } from "./arg.js";
3
- import Data from "./data.js";
4
- import { DbFindOpts, FindOpts } from "./options.js";
5
- import { VQuery } from "./query.js";
6
- import { Transaction } from "./transactions.js";
7
- import { Context } from "./types.js";
8
- export interface ValtheraCompatible {
9
- c(collection: string): CollectionManager;
10
- getCollections(): Promise<string[]>;
11
- checkCollection(collection: string): Promise<boolean>;
12
- issetCollection(collection: string): Promise<boolean>;
13
- add<T = Data>(collection: string, data: Arg, id_gen?: boolean): Promise<T>;
14
- find<T = Data>(collection: string, search: Search, context?: Context, options?: DbFindOpts, findOpts?: FindOpts): Promise<T[]>;
15
- findOne<T = Data>(collection: string, search: Search, context?: Context, findOpts?: FindOpts): Promise<T | null>;
16
- findStream<T = Data>(collection: string, search: Search, context?: Context, findOpts?: FindOpts, limit?: number): Promise<AsyncGenerator<T>>;
17
- update(collection: string, search: Search, updater: Updater, context?: Context): Promise<boolean>;
18
- updateOne(collection: string, search: Search, updater: Updater, context?: Context): Promise<boolean>;
19
- remove(collection: string, search: Search, context?: Context): Promise<boolean>;
20
- removeOne(collection: string, search: Search, context?: Context): Promise<boolean>;
21
- removeCollection(collection: string): Promise<boolean>;
22
- transaction(collection: string, transaction: Transaction[]): Promise<boolean>;
23
- updateOneOrAdd(collection: string, search: Search, updater: Updater, add_arg?: Arg, context?: Context, id_gen?: boolean): Promise<boolean>;
24
- }
25
- export interface ValtheraCompatibleInternal {
26
- c(config: VQuery): CollectionManager;
27
- getCollections(): Promise<string[]>;
28
- checkCollection(config: VQuery): Promise<boolean>;
29
- issetCollection(config: VQuery): Promise<boolean>;
30
- add<T = Data>(config: VQuery): Promise<T>;
31
- find<T = Data>(config: VQuery): Promise<T[]>;
32
- findOne<T = Data>(config: VQuery): Promise<T | null>;
33
- findStream<T = Data>(config: VQuery): Promise<AsyncGenerator<T>>;
34
- update(config: VQuery): Promise<boolean>;
35
- updateOne(config: VQuery): Promise<boolean>;
36
- remove(config: VQuery): Promise<boolean>;
37
- removeOne(config: VQuery): Promise<boolean>;
38
- removeCollection(config: VQuery): Promise<boolean>;
39
- transaction(config: VQuery): Promise<boolean>;
40
- updateOneOrAdd(config: VQuery): Promise<boolean>;
41
- }
@@ -1 +0,0 @@
1
- export {};
@@ -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,18 +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, fields) {
8
- const keys = Object.keys(fields);
9
- return keys.every(key => {
10
- if (obj[key] !== undefined) {
11
- if (typeof fields[key] === "object" && fields[key] !== null) {
12
- return hasFields(obj[key], fields[key]);
13
- }
14
- return obj[key] === fields[key];
15
- }
16
- return false;
17
- });
18
- }
@@ -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;