英文水平有限,主要靠百度翻譯!將就看!mysql
/** * 此裝飾器用於標記將是實體的類(表或文檔依賴於數據庫類型) * 數據庫模式將爲全部與它一塊兒裝飾的類建立,而且能夠檢索並使用存儲庫. */
export declare function Entity(options?: EntityOptions): Function;
export declare function Entity(name?: string, options?: EntityOptions): Function;
複製代碼
export declare type OrderByCondition = {
[columnName: string]: ("ASC" | "DESC") | {
order: "ASC" | "DESC";
nulls: "NULLS FIRST" | "NULLS LAST";
};
};
export interface EntityOptions {
/** * 表名,若是未指定,默認是類名。 */
name?: string;
/** * 默認排序 */
orderBy?: OrderByCondition | ((object: any) => OrderByCondition | any); /** * 數據庫引擎,如:"InnoDB", "MyISAM" */ engine?: string; /** * 指定數據庫名稱 */ database?: string; /** * Schema 名稱. */ schema?: string; /** * 是否爲該實體啓用或禁用架構同步 * 若是將其設置爲false,則模式同步將與遷移忽略該實體 * 默認狀況下,對全部實體啓用模式同步. */ synchronize?: boolean; } 複製代碼
export declare function ChildEntity(discriminatorValue?: any): (target: Function) => void;
複製代碼
export declare function TableInheritance(options?: {
pattern?: "STI";
column?: string | ColumnOptions;
}): (target: Function) => void;
複製代碼
export declare type OrderByCondition = {
[columnName: string]: ("ASC" | "DESC") | {
order: "ASC" | "DESC";
nulls: "NULLS FIRST" | "NULLS LAST";
};
};
export interface EntityOptions {
/** * 表名,若是未指定,默認是類名。 */
name?: string;
/** * 默認排序 */
orderBy?: OrderByCondition | ((object: any) => OrderByCondition | any); /** * 數據庫引擎,如:"InnoDB", "MyISAM" */ engine?: string; /** * 指定數據庫名稱 */ database?: string; /** * Schema 名稱. */ schema?: string; /** * 是否爲該實體啓用或禁用架構同步 * 若是將其設置爲false,則模式同步將與遷移忽略該實體 * 默認狀況下,對全部實體啓用模式同步. */ synchronize?: boolean; } 複製代碼
/**
* 用於 @PrimaryGeneratedColumn() 裝飾器的列類型.
*/
export declare type PrimaryGeneratedColumnType = "int" | "int2" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "numeric" | "number";
/**
* 帶有精度或比例的列類型.
*/
export declare type WithPrecisionColumnType = "float" | "double" | "dec" | "decimal" | "numeric" | "real" | "double precision" | "number" | "datetime" | "datetime2" | "datetimeoffset" | "time" | "time with time zone" | "time without time zone" | "timestamp" | "timestamp without time zone" | "timestamp with time zone" | "timestamp with local time zone";
/**
* 帶有長度的列類型.
*/
export declare type WithLengthColumnType = "character varying" | "varying character" | "nvarchar" | "character" | "native character" | "varchar" | "char" | "nchar" | "varchar2" | "nvarchar2" | "raw" | "binary" | "varbinary";
export declare type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" | "int" | "bigint";
/**
* 全部其餘常規列類型.
*/
export declare type SimpleColumnType = "simple-array" | "simple-json" | "bit" | "int2" | "integer" | "int4" | "int8" | "unsigned big int" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion";
/**
* 全部列類型.
*/
export declare type ColumnType = WithPrecisionColumnType | WithLengthColumnType | WithWidthColumnType | SimpleColumnType | BooleanConstructor | DateConstructor | NumberConstructor | StringConstructor;
export interface ValueTransformer {
/**
* 寫入數據庫時.
*/
to(value: any): any;
/**
* 讀取數據庫時
*/
from(value: any): any;
}
export interface ColumnOptions {
/**
* 列類型。必須是來自ColumnType類的值之一
*/
type?: ColumnType;
/**
* 列名稱.
*/
name?: string;
/**
* 列類型的長度,僅用於WithLengthColumnType|WithWidthColumnType的類型,
* 如type=string,lenght=100,將建立一個具備Varchar類型長度爲100的列.
*/
length?: string | number;
/**
* 列寬度/精度,可用於WithPrecisionColumnType.
*/
width?: number;
/**
* 列的值是否能夠設置爲空.
*/
nullable?: boolean;
/**
* 是否只讀,若是是那麼只能在insert中賦值,更新不能改變!
*/
readonly?: boolean;
/**
* 可被QueryBuilder選擇並查找。默認值爲「true」
*/
select?: boolean;
/**
* 默認值.
*/
default?: any;
/**
* 更新觸發器,僅支持mysql.
*/
onUpdate?: string;
/**
* 是否爲主鍵,與@PrimaryColumn效果相同
*/
primary?: boolean;
/**
* 是否惟一
*/
unique?: boolean;
/**
* 備註信息.
*/
comment?: string;
/**
* 十進制(精確數字)列的精度(僅適用於十進制列),這是爲值存儲的最大位數
*/
precision?: number | null;
/**
* 小數(精確數字)列的刻度(僅適用於十進制列),它表示小數點右邊的位數,不能大於精度
*/
scale?: number;
/**
* 若是爲true,MySQL會自動將未簽名的屬性添加到此列中。
*/
zerofill?: boolean;
/**
* 標註是否簽名.
*/
unsigned?: boolean;
/**
* 字符集
*/
charset?: string;
/**
* 列排序規則.
*/
collation?: string;
/**
* 規定可枚舉的數據.
*/
enum?: any[] | Object;
/**
* 生成的列表達式.
*/
asExpression?: string;
/**
* 生成的列類型.
*/
generatedType?: "VIRTUAL" | "STORED";
/**
* 返回列類型
*/
hstoreType?: "object" | "string";
/**
* 是否數組
*/
array?: boolean;
/**
* 轉換器
*/
transformer?: ValueTransformer;
}
/**
* 列裝飾器用於標記特定的類屬性做爲列。只有在保存實體時,使用該裝飾器的屬性纔會被持久化到數據庫中。
*/
export declare function Column(): Function;
export declare function Column(options: ColumnOptions): Function;
export declare function Column(type: SimpleColumnType, options?: ColumnCommonOptions): Function;
export declare function Column(type: WithLengthColumnType, options?: ColumnCommonOptions & ColumnWithLengthOptions): Function;
export declare function Column(type: WithWidthColumnType, options?: ColumnCommonOptions & ColumnWithWidthOptions): Function;
export declare function Column(type: WithPrecisionColumnType, options?: ColumnCommonOptions & ColumnNumericOptions): Function;
export declare function Column(type: "enum", options?: ColumnCommonOptions & ColumnEnumOptions): Function;
export declare function Column(type: "hstore", options?: ColumnCommonOptions & ColumnHstoreOptions): Function;
/**
* 實體中的屬性能夠標記爲嵌入式,而且在持久性上,
* 全部來自嵌入式的列都映射到使用嵌入的實體的單個表。
* 在水化過程當中,全部被嵌入的列都將從單個表映射到它。
*/
export declare function Column(type: (type?: any) => Function, options?: ColumnEmbeddedOptions): Function;
複製代碼
export interface RelationOptions {
/**
* 設置給定關係的級聯選項。
* 若是設置爲true,則意味着能夠容許在數據庫中插入或更新相關對象。
* 可使用如下語法單獨限制級聯插入或更新:
* cascade: ["insert", "update"]
*/
cascade?: boolean | ("insert" | "update" | "remove")[];
/**
* 標示關係列值是否能夠爲空值。
*/
nullable?: boolean;
/**
* 刪除數據庫時操做.
*/
onDelete?: OnDeleteType;
/**
* 更新數據庫時操做
*/
onUpdate?: OnUpdateType;
/**
* 此關係是否爲主鍵。只能用於多對一和業主一對一的關係
*/
primary?: boolean;
/**
* 是否懶加載,當使用時獲取
*/
lazy?: boolean;
/**
* find查找時,是否自動加載關係,能夠設置其中一方
*/
eager?: boolean;
/**
* 是否持久性
* 若是其已禁用,則只能更改關係的反面或使用關係查詢生成器功能
*/
persistence?: boolean;
}
/**
* 一對多
* 如: 一個員工,只能屬於一個公司,公司能夠有多個員工
* 一是公司 可能是員工 type=>員工 員工.公司 string
*/
export declare function OneToMany<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide: string | ((object: T) => any), options?: RelationOptions): Function;
複製代碼
/**
* 多對一
* 一個員工,只能屬於一個公司,公司能夠有多個員工
* 可能是公司,一是員工 type=>公司, 公司.員工 array
*/
export declare function ManyToOne<T>(typeFunction: (type?: any) => ObjectType<T>, options?: RelationOptions): Function;
export declare function ManyToOne<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide?: string | ((object: T) => any), options?: RelationOptions): Function;
複製代碼
export declare type PrimaryGeneratedColumnType = "int" | "int2" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "numeric" | "number";
/**
* PrimaryGeneratedColumn
*/
export interface PrimaryGeneratedColumnNumericOptions {
/**
* 列類型.
*/
type?: PrimaryGeneratedColumnType;
/**
* 名稱
*/
name?: string;
/**
* 備註.
*/
comment?: string;
/**
* 是否 zero fill
*/
zerofill?: boolean;
/**
* 是否unsigned
*/
unsigned?: boolean;
}
export interface PrimaryGeneratedColumnUUIDOptions {
/**
* 名稱
*/
name?: string;
/**
* 備註.
*/
comment?: string;
}
/**
* 主鍵自增
*/
export declare function PrimaryGeneratedColumn(): Function;
/**
* 主鍵自增
*/
export declare function PrimaryGeneratedColumn(options: PrimaryGeneratedColumnNumericOptions): Function;
/**
* 主鍵自增
*/
export declare function PrimaryGeneratedColumn(strategy: "increment", options?: PrimaryGeneratedColumnNumericOptions): Function;
/**
* 主鍵uuid模式
*/
export declare function PrimaryGeneratedColumn(strategy: "uuid", options?: PrimaryGeneratedColumnUUIDOptions): Function;
複製代碼
/** * PRIMARY KEY */
export declare function PrimaryColumn(options?: ColumnOptions): Function;
/** * PRIMARY KEY */
export declare function PrimaryColumn(type?: ColumnType, options?: ColumnOptions): Function;
複製代碼
// 更新日期
export declare function UpdateDateColumn(options?: ColumnOptions): Function;
複製代碼
// 插入日期
export declare function CreateDateColumn(options?: ColumnOptions): Function;
複製代碼
// 數字版本
export declare function VersionColumn(options?: ColumnOptions): Function;
複製代碼
// 插入後執行腳本
export declare function AfterInsert(): (object: Object, propertyName: string) => void;
複製代碼
// 加載後鉤子
export declare function AfterLoad(): (object: Object, propertyName: string) => void;
複製代碼
// remove後鉤子
export declare function AfterRemove(): (object: Object, propertyName: string) => void;
複製代碼
// 更新鉤子
export declare function AfterUpdate(): (object: Object, propertyName: string) => void;
複製代碼
// insert前
export declare function BeforeInsert(): (object: Object, propertyName: string) => void;
複製代碼
// remove前
export declare function BeforeRemove(): (object: Object, propertyName: string) => void;
複製代碼
// 更新前
export declare function BeforeUpdate(): (object: Object, propertyName: string) => void;
複製代碼
// 事件監聽
export declare function EventSubscriber(): (target: Function) => void;
複製代碼
export interface JoinColumnOptions {
/** * 名稱 */
name?: string;
/** * 引用該列的實體中列的名稱 */
referencedColumnName?: string;
}
/** * 一對一或多對一關係指定 */
export declare function JoinColumn(): Function;
export declare function JoinColumn(options: JoinColumnOptions): Function;
export declare function JoinColumn(options: JoinColumnOptions[]): Function;
複製代碼
export interface JoinColumnOptions {
/** * 自定義名稱 */
name?: string;
/** * 列名稱 */
referencedColumnName?: string;
}
/** * Describes join table options. */
export interface JoinTableOptions {
/** * 名稱 */
name?: string;
/** * 鏈接表的第一列 */
joinColumn?: JoinColumnOptions;
/** * 鏈接表的第二列 */
inverseJoinColumn?: JoinColumnOptions;
/** * 代表 */
database?: string;
/** * 建立鏈接表schema */
schema?: string;
}
export interface JoinTableMultipleColumnsOptions {
/** * 鏈接表值得表名稱,默認自動建立 */
name?: string;
/** * 鏈接表的第一列 */
joinColumns?: JoinColumnOptions[];
/** * 鏈接表的第二列 */
inverseJoinColumns?: JoinColumnOptions[];
/** * 數據庫 */
database?: string;
/** * schema */
schema?: string;
}
/** * 多對多關係 */
export declare function JoinTable(): Function;
export declare function JoinTable(options: JoinTableOptions): Function;
export declare function JoinTable(options: JoinTableMultipleColumnsOptions): Function;
複製代碼
export interface RelationOptions {
/**
* cascade
*/
cascade?: boolean | ("insert" | "update" | "remove")[];
/**
* 是否能夠null.
*/
nullable?: boolean;
/**
* 刪除時
*/
onDelete?: OnDeleteType;
/**
* 更新時
*/
onUpdate?: OnUpdateType;
/**
* 主鍵
*/
primary?: boolean;
/**
* 惰性加載
*/
lazy?: boolean;
/**
* eager
*/
eager?: boolean;
/**
* persistence
*/
persistence?: boolean;
}
/**
* 多對多關係,這種類型的關係建立一個鏈接表,用於保存關係數據
*/
export declare function ManyToMany<T>(typeFunction: (type?: any) => ObjectType<T>, options?: RelationOptions): Function;
export declare function ManyToMany<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide?: string | ((object: T) => any), options?: RelationOptions): Function;
複製代碼
// 多對一
export declare function ManyToOne<T>(typeFunction: (type?: any) => ObjectType<T>, options?: RelationOptions): Function;
export declare function ManyToOne<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide?: string | ((object: T) => any), options?: RelationOptions): Function;
複製代碼
// 一對多
export declare function OneToMany<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide: string | ((object: T) => any), options?: RelationOptions): Function;
複製代碼
/**
* 一對一
*/
export declare function OneToOne<T>(typeFunction: (type?: any) => ObjectType<T>, options?: RelationOptions): Function;
export declare function OneToOne<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide?: string | ((object: T) => any), options?: RelationOptions): Function;
複製代碼
// 數量
export declare function RelationCount<T>(relation: string | ((object: T) => any), alias?: string, queryBuilderFactory?: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>): Function;
複製代碼
// 提取id
export declare function RelationId<T>(relation: string | ((object: T) => any), alias?: string, queryBuilderFactory?: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>): Function;
複製代碼
/**
* 標記實體像樹同樣工做。
* 應該指定樹實體的樹模式。
* @TreeParent。
*/
export declare function Tree(type: TreeType): Function;
export declare function TreeParent(): Function;
export declare function TreeLevelColumn(): Function;
export declare function TreeChildren(options?: {
cascade?: boolean | ("insert" | "update" | "remove")[];
}): Function;
複製代碼
/** * 將一些方法封裝成事務. * * 若是想要使用實體管理器 * then use @TransactionEntityManager() decorator. * * 若是想要使用存儲庫 * then use @TransactionRepository() decorator. */
export declare function Transaction(connectionName?: string): MethodDecorator;
/** * 事物存儲庫 */
export declare function TransactionRepository(entityType?: Function): ParameterDecorator;
/** * 事物實體管理器 */
export declare function TransactionManager(): Function;
複製代碼