-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# `@eggjs/dal-decorator` | ||
|
||
## Usage | ||
|
||
Please read [@eggjs/tegg-dal-plugin](../../plugin/dal-plugin) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export * from './src/enum/CompressionType'; | ||
export * from './src/enum/InsertMethod'; | ||
export * from './src/enum/RowFormat'; | ||
export * from './src/enum/IndexType'; | ||
export * from './src/enum/ColumnType'; | ||
|
||
export * from './src/decorator/Index'; | ||
export * from './src/decorator/Table'; | ||
export * from './src/decorator/Column'; | ||
|
||
export * from './src/util/ColumnInfoUtil'; | ||
export * from './src/util/IndexInfoUtil'; | ||
export * from './src/util/TableInfoUtil'; | ||
|
||
export * from './src/model/ColumnModel'; | ||
export * from './src/model/IndexModel'; | ||
export * from './src/model/TableModel'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "@eggjs/dal-decorator", | ||
"version": "3.32.0", | ||
"description": "tegg dal decorator", | ||
"keywords": [ | ||
"egg", | ||
"typescript", | ||
"decorator", | ||
"tegg", | ||
"dal" | ||
], | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist/**/*.js", | ||
"dist/**/*.d.ts" | ||
], | ||
"typings": "dist/index.d.ts", | ||
"scripts": { | ||
"test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", | ||
"clean": "tsc -b --clean", | ||
"tsc": "npm run clean && tsc -p ./tsconfig.json", | ||
"tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", | ||
"prepublishOnly": "npm run tsc:pub" | ||
}, | ||
"author": "killagu <[email protected]>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/eggjs/tegg", | ||
"bugs": { | ||
"url": "https://github.com/eggjs/tegg/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:eggjs/tegg.git", | ||
"directory": "core/dal-decorator" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"dependencies": { | ||
"lodash.snakecase": "^4.1.1", | ||
"pluralize": "^7.0.0", | ||
"@eggjs/tegg-common-util": "^3.32.0", | ||
"@eggjs/core-decorator": "^3.32.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.2.4", | ||
"cross-env": "^7.0.3", | ||
"mocha": "^10.2.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.4" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,273 @@ | ||
import assert from 'node:assert'; | ||
import { ColumnType } from '../enum/ColumnType'; | ||
import { EggProtoImplClass } from '@eggjs/core-decorator'; | ||
import { ColumnInfoUtil } from '../util/ColumnInfoUtil'; | ||
import { ColumnFormat } from '../enum/ColumnFormat'; | ||
|
||
export interface ColumnParams { | ||
name?: string; | ||
default?: string; | ||
canNull?: boolean; | ||
comment?: string; | ||
visible?: boolean; | ||
autoIncrement?: boolean; | ||
uniqueKey?: boolean; | ||
primaryKey?: boolean; | ||
collate?: string; | ||
columnFormat?: ColumnFormat; | ||
engineAttribute?: string; | ||
secondaryEngineAttribute?: string; | ||
} | ||
|
||
export interface IColumnTypeParams { | ||
type: ColumnType; | ||
} | ||
|
||
export interface BitParams extends IColumnTypeParams { | ||
type: ColumnType.BIT, | ||
length?: number; | ||
} | ||
|
||
export interface BoolParams extends IColumnTypeParams { | ||
type: ColumnType.BOOL, | ||
} | ||
|
||
interface BaseNumericParams extends IColumnTypeParams { | ||
length?: number; | ||
unsigned?: boolean; | ||
zeroFill?: boolean; | ||
} | ||
|
||
interface BaseFloatNumericParams extends IColumnTypeParams { | ||
length?: number; | ||
fractionalLength?: number; | ||
unsigned?: boolean; | ||
zeroFill?: boolean; | ||
} | ||
|
||
export interface TinyIntParams extends BaseNumericParams { | ||
type: ColumnType.TINYINT; | ||
} | ||
|
||
export interface SmallIntParams extends BaseNumericParams { | ||
type: ColumnType.SMALLINT; | ||
} | ||
|
||
export interface MediumIntParams extends BaseNumericParams { | ||
type: ColumnType.MEDIUMINT; | ||
} | ||
|
||
export interface IntParams extends BaseNumericParams { | ||
type: ColumnType.INT; | ||
} | ||
|
||
export interface BigIntParams extends BaseNumericParams { | ||
type: ColumnType.BIGINT; | ||
} | ||
|
||
export interface DecimalParams extends BaseFloatNumericParams { | ||
type: ColumnType.DECIMAL; | ||
} | ||
|
||
export interface FloatParams extends BaseFloatNumericParams { | ||
type: ColumnType.FLOAT; | ||
} | ||
|
||
export interface DoubleParams extends BaseFloatNumericParams { | ||
type: ColumnType.DOUBLE; | ||
} | ||
|
||
export interface DateParams extends IColumnTypeParams { | ||
type: ColumnType.DATE; | ||
} | ||
|
||
export interface DateTimeParams extends IColumnTypeParams { | ||
type: ColumnType.DATETIME; | ||
precision?: number; | ||
} | ||
|
||
export interface TimestampParams extends IColumnTypeParams { | ||
type: ColumnType.TIMESTAMP; | ||
precision?: number; | ||
} | ||
|
||
export interface TimeParams extends IColumnTypeParams { | ||
type: ColumnType.TIME; | ||
precision?: number; | ||
} | ||
|
||
export interface YearParams extends IColumnTypeParams { | ||
type: ColumnType.YEAR; | ||
} | ||
|
||
export interface CharParams extends IColumnTypeParams { | ||
type: ColumnType.CHAR; | ||
length?: number; | ||
characterSet?: string; | ||
collate?: string; | ||
} | ||
|
||
export interface VarCharParams extends IColumnTypeParams { | ||
type: ColumnType.VARCHAR; | ||
length: number; | ||
characterSet?: string; | ||
collate?: string; | ||
} | ||
|
||
export interface BinaryParams extends IColumnTypeParams { | ||
type: ColumnType.BINARY; | ||
length?: number; | ||
} | ||
|
||
export interface VarBinaryParams extends IColumnTypeParams { | ||
type: ColumnType.VARBINARY; | ||
length: number; | ||
} | ||
|
||
export interface TinyBlobParams extends IColumnTypeParams { | ||
type: ColumnType.TINYBLOB; | ||
} | ||
|
||
export interface TinyTextParams extends IColumnTypeParams { | ||
type: ColumnType.TINYTEXT; | ||
characterSet?: string; | ||
collate?: string; | ||
} | ||
|
||
export interface BlobParams extends IColumnTypeParams { | ||
type: ColumnType.BLOB; | ||
length?: number; | ||
} | ||
|
||
export interface TextParams extends IColumnTypeParams { | ||
type: ColumnType.TEXT; | ||
length?: number; | ||
characterSet?: string; | ||
collate?: string; | ||
} | ||
|
||
export interface MediumBlobParams extends IColumnTypeParams { | ||
type: ColumnType.MEDIUMBLOB; | ||
} | ||
|
||
export interface LongBlobParams extends IColumnTypeParams { | ||
type: ColumnType.LONGBLOB; | ||
} | ||
|
||
export interface MediumTextParams extends IColumnTypeParams { | ||
type: ColumnType.MEDIUMTEXT; | ||
characterSet?: string; | ||
collate?: string; | ||
} | ||
|
||
export interface LongTextParams extends IColumnTypeParams { | ||
type: ColumnType.LONGTEXT; | ||
characterSet?: string; | ||
collate?: string; | ||
} | ||
|
||
export interface EnumParams extends IColumnTypeParams { | ||
type: ColumnType.ENUM; | ||
enums: string[]; | ||
characterSet?: string; | ||
collate?: string; | ||
} | ||
|
||
export interface SetParams extends IColumnTypeParams { | ||
type: ColumnType.SET; | ||
enums: string[]; | ||
characterSet?: string; | ||
collate?: string; | ||
} | ||
|
||
export interface JsonParams extends IColumnTypeParams { | ||
type: ColumnType.JSON; | ||
} | ||
|
||
export interface BaseSpatialParams extends IColumnTypeParams { | ||
SRID?: number; | ||
} | ||
|
||
export interface GeometryParams extends BaseSpatialParams { | ||
type: ColumnType.GEOMETRY; | ||
} | ||
|
||
export interface PointParams extends BaseSpatialParams { | ||
type: ColumnType.POINT; | ||
} | ||
|
||
export interface LinestringParams extends BaseSpatialParams { | ||
type: ColumnType.LINESTRING; | ||
} | ||
|
||
export interface PolygonParams extends BaseSpatialParams { | ||
type: ColumnType.POLYGON; | ||
} | ||
|
||
export interface MultipointParams extends BaseSpatialParams { | ||
type: ColumnType.MULTIPOINT; | ||
} | ||
|
||
export interface MultilinestringParams extends BaseSpatialParams { | ||
type: ColumnType.MULTILINESTRING; | ||
} | ||
|
||
export interface MultipolygonParams extends BaseSpatialParams { | ||
type: ColumnType.MULTIPOLYGON; | ||
} | ||
|
||
export interface GeometrycollectionParams extends BaseSpatialParams { | ||
type: ColumnType.GEOMETRYCOLLECTION; | ||
} | ||
|
||
export type ColumnTypeParams = BitParams | ||
| BoolParams | ||
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 224 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| TinyIntParams | ||
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 225 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| SmallIntParams | ||
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 226 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| MediumIntParams | ||
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 227 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| IntParams | ||
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 228 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| BigIntParams | ||
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 229 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| DecimalParams | ||
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 230 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| FloatParams | ||
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 231 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| DoubleParams | ||
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 232 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| DateParams | ||
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (20)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (18)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (16)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-ubuntu (14)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (14)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (16)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (20)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (18)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (14)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-windows (20)
Check failure on line 233 in core/dal-decorator/src/decorator/Column.ts GitHub Actions / Runner-macos (16)
|
||
| DateTimeParams | ||
| TimestampParams | ||
| TimeParams | ||
| YearParams | ||
| CharParams | ||
| VarCharParams | ||
| BinaryParams | ||
| VarBinaryParams | ||
| TinyBlobParams | ||
| TinyTextParams | ||
| BlobParams | ||
| TextParams | ||
| MediumBlobParams | ||
| MediumTextParams | ||
| LongBlobParams | ||
| LongTextParams | ||
| EnumParams | ||
| SetParams | ||
| JsonParams | ||
| GeometryParams | ||
| PointParams | ||
| LinestringParams | ||
| PolygonParams | ||
| MultipointParams | ||
| MultilinestringParams | ||
| MultipolygonParams | ||
| GeometrycollectionParams; | ||
|
||
export function Column(type: ColumnTypeParams, params?: ColumnParams) { | ||
return function(target: any, propertyKey: PropertyKey) { | ||
assert(typeof propertyKey === 'string', | ||
`[Column/${target.name}] expect column name be typeof string, but now is ${String(propertyKey)}`); | ||
const tableClazz = target.constructor as EggProtoImplClass; | ||
const columnName = propertyKey as string; | ||
ColumnInfoUtil.addColumnType(tableClazz, columnName, type); | ||
if (params) { | ||
ColumnInfoUtil.addColumnInfo(tableClazz, columnName, params); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IndexType } from '../enum/IndexType'; | ||
import { IndexStoreType } from '../enum/IndexStoreType'; | ||
import { EggProtoImplClass } from '@eggjs/core-decorator'; | ||
import { IndexInfoUtil } from '../util/IndexInfoUtil'; | ||
|
||
export interface IndexParams { | ||
keys: string[]; | ||
name?: string; | ||
type?: IndexType, | ||
storeType?: IndexStoreType; | ||
comment?: string; | ||
engineAttribute?: string; | ||
secondaryEngineAttribute?: string; | ||
parser?: string; | ||
} | ||
|
||
export function Index(params: IndexParams) { | ||
return function(constructor: EggProtoImplClass) { | ||
IndexInfoUtil.addIndex(constructor, params); | ||
} | ||
} |