@iamkirbki/database-handler-core 3.1.4 → 4.0.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.
- package/dist/abstract/Model.d.ts +39 -16
- package/dist/abstract/Model.d.ts.map +1 -1
- package/dist/abstract/Model.js +148 -36
- package/dist/abstract/{Schema.d.ts → SchemaTableBuilder.d.ts} +3 -8
- package/dist/abstract/SchemaTableBuilder.d.ts.map +1 -0
- package/dist/abstract/{Schema.js → SchemaTableBuilder.js} +1 -3
- package/dist/base/Database.d.ts +13 -0
- package/dist/base/Database.d.ts.map +1 -0
- package/dist/base/Database.js +27 -0
- package/dist/base/Query.d.ts +43 -0
- package/dist/base/Query.d.ts.map +1 -0
- package/dist/base/Query.js +87 -0
- package/dist/base/Record.d.ts +23 -0
- package/dist/base/Record.d.ts.map +1 -0
- package/dist/base/Record.js +72 -0
- package/dist/base/Table.d.ts +27 -0
- package/dist/base/Table.d.ts.map +1 -0
- package/dist/base/Table.js +128 -0
- package/dist/helpers/QueryStatementBuilder.d.ts +4 -35
- package/dist/helpers/QueryStatementBuilder.d.ts.map +1 -1
- package/dist/helpers/QueryStatementBuilder.js +6 -37
- package/dist/index.d.ts +13 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/interfaces/IController.d.ts +8 -0
- package/dist/interfaces/IController.d.ts.map +1 -0
- package/dist/interfaces/IController.js +1 -0
- package/dist/interfaces/IDatabaseAdapter.d.ts.map +1 -1
- package/dist/interfaces/IMigration.d.ts +6 -0
- package/dist/interfaces/IMigration.d.ts.map +1 -0
- package/dist/interfaces/IMigration.js +1 -0
- package/dist/interfaces/ISchemaBuilder.d.ts +7 -0
- package/dist/interfaces/ISchemaBuilder.d.ts.map +1 -0
- package/dist/interfaces/ISchemaBuilder.js +1 -0
- package/dist/runtime/Container.d.ts +12 -0
- package/dist/runtime/Container.d.ts.map +1 -0
- package/dist/runtime/Container.js +29 -0
- package/dist/runtime/Repository.d.ts +17 -0
- package/dist/runtime/Repository.d.ts.map +1 -0
- package/dist/runtime/Repository.js +101 -0
- package/dist/types/index.d.ts +1 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/model.d.ts +71 -0
- package/dist/types/model.d.ts.map +1 -0
- package/dist/types/model.js +2 -0
- package/dist/types/table.d.ts +6 -2
- package/dist/types/table.d.ts.map +1 -1
- package/package.json +5 -4
- package/dist/Database.d.ts +0 -98
- package/dist/Database.d.ts.map +0 -1
- package/dist/Database.js +0 -126
- package/dist/Query.d.ts +0 -143
- package/dist/Query.d.ts.map +0 -1
- package/dist/Query.js +0 -205
- package/dist/Record.d.ts +0 -125
- package/dist/Record.d.ts.map +0 -1
- package/dist/Record.js +0 -174
- package/dist/Table.d.ts +0 -158
- package/dist/Table.d.ts.map +0 -1
- package/dist/Table.js +0 -258
- package/dist/abstract/Controller.d.ts +0 -13
- package/dist/abstract/Controller.d.ts.map +0 -1
- package/dist/abstract/Controller.js +0 -6
- package/dist/abstract/Migration.d.ts +0 -6
- package/dist/abstract/Migration.d.ts.map +0 -1
- package/dist/abstract/Migration.js +0 -2
- package/dist/abstract/Schema.d.ts.map +0 -1
- package/dist/abstract/User.d.ts +0 -8
- package/dist/abstract/User.d.ts.map +0 -1
- package/dist/abstract/User.js +0 -6
package/dist/Record.d.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { inspect } from "util";
|
|
2
|
-
import Table from "./Table.js";
|
|
3
|
-
import IDatabaseAdapter from "./interfaces/IDatabaseAdapter.js";
|
|
4
|
-
/**
|
|
5
|
-
* Record class represents a single database row with methods for updates and deletion
|
|
6
|
-
* Automatically returned by Table.Records() and Table.Record() methods
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
11
|
-
*
|
|
12
|
-
* // Access values
|
|
13
|
-
* console.log(user?.values);
|
|
14
|
-
*
|
|
15
|
-
* // Update the record
|
|
16
|
-
* user?.Update({ name: 'John Doe', age: 31 });
|
|
17
|
-
*
|
|
18
|
-
* // Delete the record
|
|
19
|
-
* user?.Delete();
|
|
20
|
-
*
|
|
21
|
-
* // JSON serialization works automatically
|
|
22
|
-
* console.log(JSON.stringify(user)); // {"id": 1, "name": "John Doe", ...}
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export default class Record<ColumnValuesType> {
|
|
26
|
-
private readonly adapter;
|
|
27
|
-
private _values;
|
|
28
|
-
private readonly _table;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a Record instance (typically called internally by Table methods)
|
|
31
|
-
*
|
|
32
|
-
* @param values - Object containing column names and their values
|
|
33
|
-
* @param db - Database connection instance
|
|
34
|
-
* @param tableName - Name of the table this record belongs to
|
|
35
|
-
*/
|
|
36
|
-
constructor(values: ColumnValuesType, adapter: IDatabaseAdapter, table: Table);
|
|
37
|
-
/**
|
|
38
|
-
* Get the raw values object for this record
|
|
39
|
-
*
|
|
40
|
-
* @returns Object containing all column values
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
45
|
-
* console.log(user?.values); // { id: 1, name: 'John', email: 'john@example.com' }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
get values(): ColumnValuesType;
|
|
49
|
-
/**
|
|
50
|
-
* Update this record in the database
|
|
51
|
-
* Updates both the database and the local values
|
|
52
|
-
*
|
|
53
|
-
* @template TEntity - Record type that must include an 'id' property (number or string)
|
|
54
|
-
* @param newValues - Object with column names and new values to update
|
|
55
|
-
* @throws Error if the record doesn't have an 'id' field
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
60
|
-
* user?.Update({ name: 'Jane Doe', age: 28 });
|
|
61
|
-
* // Database is updated and user.values reflects the changes
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
Update(newValues: object): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Delete this record from the database
|
|
67
|
-
* Uses all current field values as WHERE clause conditions
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
72
|
-
* user?.Delete();
|
|
73
|
-
* // Record is permanently deleted from the database
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
Delete(): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Returns the values object when JSON.stringify() is called
|
|
79
|
-
* Allows seamless JSON serialization of Record objects
|
|
80
|
-
*
|
|
81
|
-
* @returns The values object
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```typescript
|
|
85
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
86
|
-
* console.log(JSON.stringify(user));
|
|
87
|
-
* // Output: {"id":1,"name":"John","email":"john@example.com"}
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
toJSON(): ColumnValuesType;
|
|
91
|
-
/**
|
|
92
|
-
* Returns a formatted string representation of the record
|
|
93
|
-
*
|
|
94
|
-
* @returns Pretty-printed JSON string of the values
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```typescript
|
|
98
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
99
|
-
* console.log(user?.toString());
|
|
100
|
-
* // Output:
|
|
101
|
-
* // {
|
|
102
|
-
* // "id": 1,
|
|
103
|
-
* // "name": "John",
|
|
104
|
-
* // "email": "john@example.com"
|
|
105
|
-
* // }
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
toString(): string;
|
|
109
|
-
/**
|
|
110
|
-
* Custom inspect method for console.log() and Node.js REPL
|
|
111
|
-
* Makes Record objects display their values directly instead of the class structure
|
|
112
|
-
*
|
|
113
|
-
* @returns The values object for display
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
118
|
-
* console.log(user);
|
|
119
|
-
* // Output: { id: 1, name: 'John', email: 'john@example.com' }
|
|
120
|
-
* // Instead of: Record { _db: ..., _values: {...}, _tableName: '...' }
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
[inspect.custom](): ColumnValuesType;
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=Record.d.ts.map
|
package/dist/Record.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Record.d.ts","sourceRoot":"","sources":["../src/Record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,MAAM,YAAY,CAAC;AAG/B,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAGhE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM,CAAC,gBAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,OAAO,CAA4C;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAE/B;;;;;;OAMG;gBACS,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK;IAM7E;;;;;;;;;;OAUG;IACH,IAAW,MAAM,IAAI,gBAAgB,CAEpC;IAED;;;;;;;;;;;;;;OAcG;IACU,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BrD;;;;;;;;;;OAUG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAUpC;;;;;;;;;;;;OAYG;IACI,MAAM,IAAI,gBAAgB;IAIjC;;;;;;;;;;;;;;;;OAgBG;IACI,QAAQ,IAAI,MAAM;IAIzB;;;;;;;;;;;;;OAaG;IACH,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,gBAAgB;CAGvC"}
|
package/dist/Record.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { inspect } from "util";
|
|
11
|
-
import Query from "./Query.js";
|
|
12
|
-
/**
|
|
13
|
-
* Record class represents a single database row with methods for updates and deletion
|
|
14
|
-
* Automatically returned by Table.Records() and Table.Record() methods
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
19
|
-
*
|
|
20
|
-
* // Access values
|
|
21
|
-
* console.log(user?.values);
|
|
22
|
-
*
|
|
23
|
-
* // Update the record
|
|
24
|
-
* user?.Update({ name: 'John Doe', age: 31 });
|
|
25
|
-
*
|
|
26
|
-
* // Delete the record
|
|
27
|
-
* user?.Delete();
|
|
28
|
-
*
|
|
29
|
-
* // JSON serialization works automatically
|
|
30
|
-
* console.log(JSON.stringify(user)); // {"id": 1, "name": "John Doe", ...}
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export default class Record {
|
|
34
|
-
/**
|
|
35
|
-
* Creates a Record instance (typically called internally by Table methods)
|
|
36
|
-
*
|
|
37
|
-
* @param values - Object containing column names and their values
|
|
38
|
-
* @param db - Database connection instance
|
|
39
|
-
* @param tableName - Name of the table this record belongs to
|
|
40
|
-
*/
|
|
41
|
-
constructor(values, adapter, table) {
|
|
42
|
-
this._values = {};
|
|
43
|
-
this._values = values;
|
|
44
|
-
this.adapter = adapter;
|
|
45
|
-
this._table = table;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the raw values object for this record
|
|
49
|
-
*
|
|
50
|
-
* @returns Object containing all column values
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
55
|
-
* console.log(user?.values); // { id: 1, name: 'John', email: 'john@example.com' }
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
get values() {
|
|
59
|
-
return this._values;
|
|
60
|
-
}
|
|
61
|
-
;
|
|
62
|
-
/**
|
|
63
|
-
* Update this record in the database
|
|
64
|
-
* Updates both the database and the local values
|
|
65
|
-
*
|
|
66
|
-
* @template TEntity - Record type that must include an 'id' property (number or string)
|
|
67
|
-
* @param newValues - Object with column names and new values to update
|
|
68
|
-
* @throws Error if the record doesn't have an 'id' field
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
73
|
-
* user?.Update({ name: 'Jane Doe', age: 28 });
|
|
74
|
-
* // Database is updated and user.values reflects the changes
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
Update(newValues) {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const setClauses = Object.keys(newValues)
|
|
80
|
-
.map(key => `${key} = @${key}`)
|
|
81
|
-
.join(", ");
|
|
82
|
-
const originalValues = this._values;
|
|
83
|
-
if (originalValues.updated_at !== undefined) {
|
|
84
|
-
newValues.updated_at = new Date().toISOString();
|
|
85
|
-
}
|
|
86
|
-
const whereClauses = Object.keys(originalValues)
|
|
87
|
-
.map(key => `${key} = @where_${key}`)
|
|
88
|
-
.join(" AND ");
|
|
89
|
-
const query = `UPDATE "${this._table.Name}" SET ${setClauses} WHERE ${whereClauses};`;
|
|
90
|
-
const _query = new Query(this._table, query, this.adapter);
|
|
91
|
-
const params = Object.assign({}, newValues);
|
|
92
|
-
Object.entries(originalValues).forEach(([key, value]) => {
|
|
93
|
-
params[`where_${key}`] = value;
|
|
94
|
-
});
|
|
95
|
-
_query.Parameters = params;
|
|
96
|
-
yield _query.Run();
|
|
97
|
-
this._values = Object.assign(Object.assign({}, this._values), newValues);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Delete this record from the database
|
|
102
|
-
* Uses all current field values as WHERE clause conditions
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```typescript
|
|
106
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
107
|
-
* user?.Delete();
|
|
108
|
-
* // Record is permanently deleted from the database
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
Delete() {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const whereClauses = Object.keys(this._values)
|
|
114
|
-
.map(key => `${key} = @${key}`)
|
|
115
|
-
.join(" AND ");
|
|
116
|
-
const _query = new Query(this._table, `DELETE FROM "${this._table.Name}" WHERE ${whereClauses};`, this.adapter);
|
|
117
|
-
_query.Parameters = Object.assign({}, this._values);
|
|
118
|
-
yield _query.Run();
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Returns the values object when JSON.stringify() is called
|
|
123
|
-
* Allows seamless JSON serialization of Record objects
|
|
124
|
-
*
|
|
125
|
-
* @returns The values object
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```typescript
|
|
129
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
130
|
-
* console.log(JSON.stringify(user));
|
|
131
|
-
* // Output: {"id":1,"name":"John","email":"john@example.com"}
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
toJSON() {
|
|
135
|
-
return this._values;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Returns a formatted string representation of the record
|
|
139
|
-
*
|
|
140
|
-
* @returns Pretty-printed JSON string of the values
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```typescript
|
|
144
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
145
|
-
* console.log(user?.toString());
|
|
146
|
-
* // Output:
|
|
147
|
-
* // {
|
|
148
|
-
* // "id": 1,
|
|
149
|
-
* // "name": "John",
|
|
150
|
-
* // "email": "john@example.com"
|
|
151
|
-
* // }
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
toString() {
|
|
155
|
-
return JSON.stringify(this._values, null, 2);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Custom inspect method for console.log() and Node.js REPL
|
|
159
|
-
* Makes Record objects display their values directly instead of the class structure
|
|
160
|
-
*
|
|
161
|
-
* @returns The values object for display
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```typescript
|
|
165
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
166
|
-
* console.log(user);
|
|
167
|
-
* // Output: { id: 1, name: 'John', email: 'john@example.com' }
|
|
168
|
-
* // Instead of: Record { _db: ..., _values: {...}, _tableName: '...' }
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
[inspect.custom]() {
|
|
172
|
-
return this._values;
|
|
173
|
-
}
|
|
174
|
-
}
|
package/dist/Table.d.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import IDatabaseAdapter from "./interfaces/IDatabaseAdapter.js";
|
|
2
|
-
import { QueryOptions, ReadableTableColumnInfo, TableColumnInfo, DefaultQueryOptions, QueryWhereParameters } from "./types/index.js";
|
|
3
|
-
import Record from "./Record.js";
|
|
4
|
-
/**
|
|
5
|
-
* Table class for interacting with a specific database table
|
|
6
|
-
* Provides methods for querying, inserting, and retrieving table metadata
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const users = db.Table('users');
|
|
11
|
-
*
|
|
12
|
-
* // Get all records
|
|
13
|
-
* const allUsers = users.Records();
|
|
14
|
-
*
|
|
15
|
-
* // Get filtered records
|
|
16
|
-
* const activeUsers = users.Records({
|
|
17
|
-
* where: { status: 'active' }
|
|
18
|
-
* });
|
|
19
|
-
*
|
|
20
|
-
* // Insert a record
|
|
21
|
-
* users.Insert({ name: 'John', email: 'john@example.com' });
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export default class Table {
|
|
25
|
-
private readonly name;
|
|
26
|
-
private readonly adapter;
|
|
27
|
-
/**
|
|
28
|
-
* Private constructor - use Table.create() instead
|
|
29
|
-
*
|
|
30
|
-
* @param name - Name of the table
|
|
31
|
-
* @param adapter - Database adapter instance
|
|
32
|
-
*/
|
|
33
|
-
private constructor();
|
|
34
|
-
/**
|
|
35
|
-
* Create a Table instance (async factory method)
|
|
36
|
-
*
|
|
37
|
-
* @param name - Name of the table
|
|
38
|
-
* @param adapter - Database adapter instance
|
|
39
|
-
* @param skipValidation - Skip table existence validation (used when creating new tables)
|
|
40
|
-
* @returns Table instance
|
|
41
|
-
* @throws Error if the table does not exist in the database
|
|
42
|
-
*/
|
|
43
|
-
static create(name: string, adapter: IDatabaseAdapter, skipValidation?: boolean): Promise<Table>;
|
|
44
|
-
/**
|
|
45
|
-
* Get the name of the table
|
|
46
|
-
*
|
|
47
|
-
* @returns The table name
|
|
48
|
-
*/
|
|
49
|
-
get Name(): string;
|
|
50
|
-
/**
|
|
51
|
-
* Get raw column information from SQLite PRAGMA
|
|
52
|
-
*
|
|
53
|
-
* @returns Array of column metadata from SQLite
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* const columns = await table.TableColumnInformation();
|
|
58
|
-
* // [{ cid: 0, name: 'id', type: 'INTEGER', notnull: 0, dflt_value: null, pk: 1 }, ...]
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
TableColumnInformation(): Promise<TableColumnInfo[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Get readable, formatted column information
|
|
64
|
-
*
|
|
65
|
-
* @returns Array of formatted column metadata with readable properties
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* const columns = await table.ReadableTableColumnInformation();
|
|
70
|
-
* // [{ name: 'id', type: 'INTEGER', nullable: false, isPrimaryKey: true, defaultValue: null }, ...]
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
ReadableTableColumnInformation(): Promise<ReadableTableColumnInfo[]>;
|
|
74
|
-
Drop(): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Fetch records from the table with optional filtering, ordering, and pagination
|
|
77
|
-
* @param options Query options for selecting records
|
|
78
|
-
* @returns Array of records matching the criteria
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* // Get all records
|
|
82
|
-
* table.Records();
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* // Get specific columns with filters
|
|
86
|
-
* table.Records({
|
|
87
|
-
* select: 'id, name',
|
|
88
|
-
* where: { status: 'active', age: 25 }
|
|
89
|
-
* });
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* // With ordering and pagination
|
|
93
|
-
* table.Records({
|
|
94
|
-
* orderBy: 'created_at DESC',
|
|
95
|
-
* limit: 10,
|
|
96
|
-
* offset: 20
|
|
97
|
-
* });
|
|
98
|
-
*/
|
|
99
|
-
Records<Type>(options?: DefaultQueryOptions & QueryOptions): Promise<Record<Type>[]>;
|
|
100
|
-
/**
|
|
101
|
-
* Fetch a single record from the table
|
|
102
|
-
*
|
|
103
|
-
* @param options - Query options for selecting a record
|
|
104
|
-
* @param options.select - Columns to select (default: "*")
|
|
105
|
-
* @param options.where - Filter conditions as key-value pairs
|
|
106
|
-
* @param options.orderBy - SQL ORDER BY clause (e.g., "created_at DESC")
|
|
107
|
-
* @returns Single Record instance or undefined if not found
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```typescript
|
|
111
|
-
* // Get record by ID
|
|
112
|
-
* const user = table.Record({ where: { id: 1 } });
|
|
113
|
-
*
|
|
114
|
-
* // Get most recent record
|
|
115
|
-
* const latest = table.Record({ orderBy: 'created_at DESC' });
|
|
116
|
-
*
|
|
117
|
-
* // Update the record
|
|
118
|
-
* user?.update({ status: 'inactive' });
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
Record<Type>(options?: DefaultQueryOptions & QueryOptions): Promise<Record<Type> | undefined>;
|
|
122
|
-
/**
|
|
123
|
-
* Get the total count of records in the table
|
|
124
|
-
*
|
|
125
|
-
* @returns Number of records in the table
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```typescript
|
|
129
|
-
* const totalUsers = table.RecordsCount;
|
|
130
|
-
* console.log(`Total users: ${totalUsers}`);
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
RecordsCount(): Promise<number>;
|
|
134
|
-
/**
|
|
135
|
-
* Insert one or multiple records into the table
|
|
136
|
-
* Validates data types against table schema before insertion
|
|
137
|
-
*
|
|
138
|
-
* @param values - Single object or array of objects to insert
|
|
139
|
-
* @returns Insert result with lastInsertRowid and changes count
|
|
140
|
-
* @throws Error if values is empty or contains no columns
|
|
141
|
-
* @throws Error if validation fails (wrong types, missing required fields)
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* ```typescript
|
|
145
|
-
* // Insert single record
|
|
146
|
-
* const result = table.Insert({ name: 'John', age: 30 });
|
|
147
|
-
* console.log(`Inserted row ID: ${result.lastInsertRowid}`);
|
|
148
|
-
*
|
|
149
|
-
* // Insert multiple records (uses transaction for atomicity)
|
|
150
|
-
* table.Insert([
|
|
151
|
-
* { name: 'John', age: 30 },
|
|
152
|
-
* { name: 'Jane', age: 25 }
|
|
153
|
-
* ]);
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
|
-
Insert<Type>(values: QueryWhereParameters): Promise<Record<Type> | undefined>;
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=Table.d.ts.map
|
package/dist/Table.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../src/Table.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,EACH,YAAY,EACZ,uBAAuB,EAEvB,eAAe,EACf,mBAAmB,EAEnB,oBAAoB,EACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAE3C;;;;;OAKG;IACH,OAAO;IAKP;;;;;;;;OAQG;WACiB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,cAAc,UAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAe3G;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;;;;;;;OAUG;IACU,sBAAsB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAIjE;;;;;;;;;;OAUG;IACU,8BAA8B,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAWpE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,OAAO,CAAC,IAAI,EACrB,OAAO,CAAC,EAAE,mBAAmB,GAAG,YAAY,GAC7C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IAoB1B;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,MAAM,CAAC,IAAI,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAAG,YAAY,GAC7C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IAWpC;;;;;;;;;;OAUG;IACU,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAM5C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACU,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;CAgG7F"}
|