@tstdl/base 0.93.27 → 0.93.28
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/orm/decorators.d.ts
CHANGED
|
@@ -202,14 +202,14 @@ export declare function Unique<T extends AnyEntity>(columns: Columns<T>, options
|
|
|
202
202
|
* @param name Optional name for the index.
|
|
203
203
|
* @param options Additional index options (e.g., method, uniqueness, conditions).
|
|
204
204
|
*/
|
|
205
|
-
export declare function Index<T extends BaseEntity =
|
|
205
|
+
export declare function Index<T extends BaseEntity = BaseEntity>(options?: IndexReflectionData<T>['options']): PropertyDecorator;
|
|
206
206
|
/**
|
|
207
207
|
* Define a composite index on multiple columns.
|
|
208
208
|
* @template T The entity type.
|
|
209
209
|
* @param columns An array of property names (or tuples with direction) included in the index.
|
|
210
210
|
* @param options Additional index options.
|
|
211
211
|
*/
|
|
212
|
-
export declare function Index<T extends BaseEntity
|
|
212
|
+
export declare function Index<T extends BaseEntity>(columns: NonNullable<IndexReflectionData<T>['columns']>, options?: IndexReflectionData<T>['options']): ClassDecorator;
|
|
213
213
|
/**
|
|
214
214
|
* Automatically expire records after a certain time to live (TTL) based on the createTimestamp metadata. Requires extension of {@link Entity} instead of {@link BaseEntity}.
|
|
215
215
|
* @param ttl Time To Live in milliseconds.
|
package/orm/decorators.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createClassDecorator, createDecorator, createPropertyDecorator } from '../reflection/index.js';
|
|
2
2
|
import { Property } from '../schema/index.js';
|
|
3
3
|
import { filterUndefinedObjectProperties, objectEntries, propertyNameOf } from '../utils/object/index.js';
|
|
4
|
-
import { isArray, isString, isUndefined } from '../utils/type-guards.js';
|
|
4
|
+
import { isArray, isFunction, isString, isUndefined } from '../utils/type-guards.js';
|
|
5
5
|
/**
|
|
6
6
|
* Merges ORM reflection data into the target's metadata.
|
|
7
7
|
* @param metadata The metadata object for the class or property.
|
|
@@ -122,7 +122,7 @@ export function Unique(columnsOrOptions, options) {
|
|
|
122
122
|
return createColumnDecorator({ unique: { options: columnsOrOptions } });
|
|
123
123
|
}
|
|
124
124
|
export function Index(columnsOrOptions, options) {
|
|
125
|
-
if (isArray(columnsOrOptions)) {
|
|
125
|
+
if (isArray(columnsOrOptions) || isFunction(columnsOrOptions)) {
|
|
126
126
|
return createTableDecorator({ index: [{ columns: columnsOrOptions, options }] });
|
|
127
127
|
}
|
|
128
128
|
return createColumnDecorator({ index: { options: columnsOrOptions } });
|
|
@@ -73,7 +73,6 @@ export function _getDrizzleTableFromType(type, fallbackSchemaName) {
|
|
|
73
73
|
return column;
|
|
74
74
|
});
|
|
75
75
|
const indexFn = (data.options?.unique == true) ? uniqueIndex : index;
|
|
76
|
-
console.log({ name: data.options?.name ?? getIndexName(tableName, columns, { naming: data.options?.naming }) });
|
|
77
76
|
let builder = indexFn(data.options?.name ?? getIndexName(tableName, columns, { naming: data.options?.naming })).using(data.options?.using ?? 'btree', ...columns);
|
|
78
77
|
if (isDefined(data.options?.where)) {
|
|
79
78
|
const query = convertQuery(data.options.where(table), table, columnDefinitionsMap);
|