@cheetah.js/orm 0.1.83 → 0.1.85
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseEntity } from '../domain/base-entity';
|
|
2
2
|
import { SqlBuilder } from '../SqlBuilder';
|
|
3
|
-
import { FilterQuery, ValueOrInstance } from '../driver/driver.interface';
|
|
3
|
+
import { FilterQuery, FindOptions, ValueOrInstance } from '../driver/driver.interface';
|
|
4
4
|
/**
|
|
5
5
|
* Generic Repository class for database operations.
|
|
6
6
|
* Provides type-safe methods for CRUD operations.
|
|
@@ -109,24 +109,12 @@ export declare abstract class Repository<T extends BaseEntity> {
|
|
|
109
109
|
*/
|
|
110
110
|
exists(where: FilterQuery<T>): Promise<boolean>;
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Order options for repository queries.
|
|
114
|
-
*/
|
|
115
|
-
export type RepositoryOrderOptions<T> = {
|
|
116
|
-
[K in keyof T]?: 'ASC' | 'DESC';
|
|
117
|
-
};
|
|
118
112
|
/**
|
|
119
113
|
* Find options for repository queries.
|
|
120
114
|
*/
|
|
121
|
-
export
|
|
115
|
+
export type RepositoryFindOptions<T> = FindOptions<T> & {
|
|
122
116
|
where?: FilterQuery<T>;
|
|
123
|
-
|
|
124
|
-
limit?: number;
|
|
125
|
-
offset?: number;
|
|
126
|
-
fields?: readonly (keyof T)[];
|
|
127
|
-
load?: readonly string[];
|
|
128
|
-
loadStrategy?: 'select' | 'joined';
|
|
129
|
-
}
|
|
117
|
+
};
|
|
130
118
|
/**
|
|
131
119
|
* Find one options for repository queries.
|
|
132
120
|
*/
|
|
@@ -45,9 +45,9 @@ class Repository {
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
async find(options) {
|
|
48
|
-
const { where,
|
|
48
|
+
const { where, orderBy, limit, offset, fields, load, loadStrategy } = options;
|
|
49
49
|
return this.entityClass.find(where || {}, {
|
|
50
|
-
orderBy:
|
|
50
|
+
orderBy: orderBy,
|
|
51
51
|
limit,
|
|
52
52
|
offset,
|
|
53
53
|
fields: fields,
|
|
@@ -60,9 +60,9 @@ class Repository {
|
|
|
60
60
|
* Returns undefined if not found.
|
|
61
61
|
*/
|
|
62
62
|
async findOne(options) {
|
|
63
|
-
const { where,
|
|
63
|
+
const { where, orderBy, fields, load, loadStrategy } = options;
|
|
64
64
|
return this.entityClass.findOne(where || {}, {
|
|
65
|
-
orderBy:
|
|
65
|
+
orderBy: orderBy,
|
|
66
66
|
fields: fields,
|
|
67
67
|
load: load,
|
|
68
68
|
loadStrategy,
|
|
@@ -73,9 +73,9 @@ class Repository {
|
|
|
73
73
|
* Throws an error if not found.
|
|
74
74
|
*/
|
|
75
75
|
async findOneOrFail(options) {
|
|
76
|
-
const { where,
|
|
76
|
+
const { where, orderBy, fields, load, loadStrategy } = options;
|
|
77
77
|
return this.entityClass.findOneOrFail(where || {}, {
|
|
78
|
-
orderBy:
|
|
78
|
+
orderBy: orderBy,
|
|
79
79
|
fields: fields,
|
|
80
80
|
load: load,
|
|
81
81
|
loadStrategy,
|
|
@@ -85,9 +85,9 @@ class Repository {
|
|
|
85
85
|
* Finds all entities with optional filtering.
|
|
86
86
|
*/
|
|
87
87
|
async findAll(options) {
|
|
88
|
-
const {
|
|
88
|
+
const { orderBy, limit, offset, fields, load, loadStrategy } = options || {};
|
|
89
89
|
return this.entityClass.findAll({
|
|
90
|
-
orderBy:
|
|
90
|
+
orderBy: orderBy,
|
|
91
91
|
limit,
|
|
92
92
|
offset,
|
|
93
93
|
fields: fields,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheetah.js/orm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.85",
|
|
4
4
|
"description": "A simple ORM for Cheetah.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"bun",
|
|
56
56
|
"value-object"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "ba6b49bd9db20c946f531f81a3f969b9acc1e663"
|
|
59
59
|
}
|