@cheetah.js/orm 0.1.85 → 0.1.86

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.
@@ -45,30 +45,30 @@ export declare abstract class Repository<T extends BaseEntity> {
45
45
  * });
46
46
  * ```
47
47
  */
48
- find(options: RepositoryFindOptions<T>): Promise<T[]>;
48
+ find<Hint extends string = never>(options: RepositoryFindOptions<T, Hint>): Promise<T[]>;
49
49
  /**
50
50
  * Finds a single entity matching the given criteria.
51
51
  * Returns undefined if not found.
52
52
  */
53
- findOne(options: RepositoryFindOneOptions<T>): Promise<T | undefined>;
53
+ findOne<Hint extends string = never>(options: RepositoryFindOneOptions<T, Hint>): Promise<T | undefined>;
54
54
  /**
55
55
  * Finds a single entity matching the given criteria.
56
56
  * Throws an error if not found.
57
57
  */
58
- findOneOrFail(options: RepositoryFindOneOptions<T>): Promise<T>;
58
+ findOneOrFail<Hint extends string = never>(options: RepositoryFindOneOptions<T, Hint>): Promise<T>;
59
59
  /**
60
60
  * Finds all entities with optional filtering.
61
61
  */
62
- findAll(options?: Omit<RepositoryFindOptions<T>, 'where'>): Promise<T[]>;
62
+ findAll<Hint extends string = never>(options?: Omit<RepositoryFindOptions<T>, 'where'>): Promise<T[]>;
63
63
  /**
64
64
  * Finds an entity by its primary key.
65
65
  */
66
- findById(id: number | string): Promise<T | undefined>;
66
+ findById<Hint extends string = never>(id: number | string, options?: Omit<RepositoryFindOneOptions<T, Hint>, 'where'>): Promise<T | undefined>;
67
67
  /**
68
68
  * Finds an entity by its primary key.
69
69
  * Throws an error if not found.
70
70
  */
71
- findByIdOrFail(id: number | string): Promise<T>;
71
+ findByIdOrFail<Hint extends string = never>(id: number | string, options?: Omit<RepositoryFindOneOptions<T, Hint>, 'where'>): Promise<T>;
72
72
  /**
73
73
  * Creates a new entity.
74
74
  */
@@ -112,10 +112,10 @@ export declare abstract class Repository<T extends BaseEntity> {
112
112
  /**
113
113
  * Find options for repository queries.
114
114
  */
115
- export type RepositoryFindOptions<T> = FindOptions<T> & {
115
+ export type RepositoryFindOptions<T, Hint extends string = never> = FindOptions<T, Hint> & {
116
116
  where?: FilterQuery<T>;
117
117
  };
118
118
  /**
119
119
  * Find one options for repository queries.
120
120
  */
121
- export type RepositoryFindOneOptions<T> = Omit<RepositoryFindOptions<T>, 'limit' | 'offset'>;
121
+ export type RepositoryFindOneOptions<T, Hint extends string = never> = Omit<RepositoryFindOptions<T, Hint>, 'limit' | 'offset'>;
@@ -98,15 +98,15 @@ class Repository {
98
98
  /**
99
99
  * Finds an entity by its primary key.
100
100
  */
101
- async findById(id) {
102
- return this.findOne({ where: { id } });
101
+ async findById(id, options) {
102
+ return this.findOne({ where: { id }, ...options });
103
103
  }
104
104
  /**
105
105
  * Finds an entity by its primary key.
106
106
  * Throws an error if not found.
107
107
  */
108
- async findByIdOrFail(id) {
109
- return this.findOneOrFail({ where: { id } });
108
+ async findByIdOrFail(id, options) {
109
+ return this.findOneOrFail({ where: { id }, ...options });
110
110
  }
111
111
  /**
112
112
  * Creates a new entity.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cheetah.js/orm",
3
- "version": "0.1.85",
3
+ "version": "0.1.86",
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": "ba6b49bd9db20c946f531f81a3f969b9acc1e663"
58
+ "gitHead": "892dcc7a37c62b283b9bebb810bd2a0ab560e20e"
59
59
  }