当前位置:   article > 正文

typeorm整理翻译

typeorm transformer

英文水平有限,主要靠百度翻译!将就看!

Entity
Entity
  1. /**
  2. * 此装饰器用于标记将是实体的类(表或文档依赖于数据库类型)
  3. * 数据库模式将为所有与它一起装饰的类创建,并且可以检索并使用存储库.
  4. */
  5. export declare function Entity(options?: EntityOptions): Function;
  6. export declare function Entity(name?: string, options?: EntityOptions): Function;
  7. 复制代码
  1. export declare type OrderByCondition = {
  2. [columnName: string]: ("ASC" | "DESC") | {
  3. order: "ASC" | "DESC";
  4. nulls: "NULLS FIRST" | "NULLS LAST";
  5. };
  6. };
  7. export interface EntityOptions {
  8. /**
  9. * 表名,如果未指定,默认是类名。
  10. */
  11. name?: string;
  12. /**
  13. * 默认排序
  14. */
  15. orderBy?: OrderByCondition | ((object: any) => OrderByCondition | any);
  16. /**
  17. * 数据库引擎,如:"InnoDB", "MyISAM"
  18. */
  19. engine?: string;
  20. /**
  21. * 指定数据库名称
  22. */
  23. database?: string;
  24. /**
  25. * Schema 名称.
  26. */
  27. schema?: string;
  28. /**
  29. * 是否为该实体启用或禁用架构同步
  30. * 如果将其设置为false,则模式同步将与迁移忽略该实体
  31. * 默认情况下,对所有实体启用模式同步.
  32. */
  33. synchronize?: boolean;
  34. }
  35. 复制代码
ChildEntity
  1. export declare function ChildEntity(discriminatorValue?: any): (target: Function) => void;
  2. 复制代码
TableInheritance
  1. export declare function TableInheritance(options?: {
  2. pattern?: "STI";
  3. column?: string | ColumnOptions;
  4. }): (target: Function) => void;
  5. 复制代码
  1. export declare type OrderByCondition = {
  2. [columnName: string]: ("ASC" | "DESC") | {
  3. order: "ASC" | "DESC";
  4. nulls: "NULLS FIRST" | "NULLS LAST";
  5. };
  6. };
  7. export interface EntityOptions {
  8. /**
  9. * 表名,如果未指定,默认是类名。
  10. */
  11. name?: string;
  12. /**
  13. * 默认排序
  14. */
  15. orderBy?: OrderByCondition | ((object: any) => OrderByCondition | any);
  16. /**
  17. * 数据库引擎,如:"InnoDB", "MyISAM"
  18. */
  19. engine?: string;
  20. /**
  21. * 指定数据库名称
  22. */
  23. database?: string;
  24. /**
  25. * Schema 名称.
  26. */
  27. schema?: string;
  28. /**
  29. * 是否为该实体启用或禁用架构同步
  30. * 如果将其设置为false,则模式同步将与迁移忽略该实体
  31. * 默认情况下,对所有实体启用模式同步.
  32. */
  33. synchronize?: boolean;
  34. }
  35. 复制代码

Column

  1. /**
  2. * 用于 @PrimaryGeneratedColumn() 装饰器的列类型.
  3. */
  4. export declare type PrimaryGeneratedColumnType = "int" | "int2" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "numeric" | "number";
  5. /**
  6. * 带有精度或比例的列类型.
  7. */
  8. 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";
  9. /**
  10. * 带有长度的列类型.
  11. */
  12. export declare type WithLengthColumnType = "character varying" | "varying character" | "nvarchar" | "character" | "native character" | "varchar" | "char" | "nchar" | "varchar2" | "nvarchar2" | "raw" | "binary" | "varbinary";
  13. export declare type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" | "int" | "bigint";
  14. /**
  15. * 所有其他常规列类型.
  16. */
  17. 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";
  18. /**
  19. * 所有列类型.
  20. */
  21. export declare type ColumnType = WithPrecisionColumnType | WithLengthColumnType | WithWidthColumnType | SimpleColumnType | BooleanConstructor | DateConstructor | NumberConstructor | StringConstructor;
  22. export interface ValueTransformer {
  23. /**
  24. * 写入数据库时.
  25. */
  26. to(value: any): any;
  27. /**
  28. * 读取数据库时
  29. */
  30. from(value: any): any;
  31. }
  32. export interface ColumnOptions {
  33. /**
  34. * 列类型。必须是来自ColumnType类的值之一
  35. */
  36. type?: ColumnType;
  37. /**
  38. * 列名称.
  39. */
  40. name?: string;
  41. /**
  42. * 列类型的长度,仅用于WithLengthColumnType|WithWidthColumnType的类型,
  43. * 如type=string,lenght=100,将创建一个具有Varchar类型长度为100的列.
  44. */
  45. length?: string | number;
  46. /**
  47. * 列宽度/精度,可用于WithPrecisionColumnType.
  48. */
  49. width?: number;
  50. /**
  51. * 列的值是否可以设置为空.
  52. */
  53. nullable?: boolean;
  54. /**
  55. * 是否只读,如果是那么只能在insert中赋值,更新不能改变!
  56. */
  57. readonly?: boolean;
  58. /**
  59. * 可被QueryBuilder选择并查找。默认值为“true”
  60. */
  61. select?: boolean;
  62. /**
  63. * 默认值.
  64. */
  65. default?: any;
  66. /**
  67. * 更新触发器,仅支持mysql.
  68. */
  69. onUpdate?: string;
  70. /**
  71. * 是否为主键,与@PrimaryColumn效果相同
  72. */
  73. primary?: boolean;
  74. /**
  75. * 是否唯一
  76. */
  77. unique?: boolean;
  78. /**
  79. * 备注信息.
  80. */
  81. comment?: string;
  82. /**
  83. * 十进制(精确数字)列的精度(仅适用于十进制列),这是为值存储的最大位数
  84. */
  85. precision?: number | null;
  86. /**
  87. * 小数(精确数字)列的刻度(仅适用于十进制列),它表示小数点右边的位数,不能大于精度
  88. */
  89. scale?: number;
  90. /**
  91. * 如果为true,MySQL会自动将未签名的属性添加到此列中。
  92. */
  93. zerofill?: boolean;
  94. /**
  95. * 标注是否签名.
  96. */
  97. unsigned?: boolean;
  98. /**
  99. * 字符集
  100. */
  101. charset?: string;
  102. /**
  103. * 列排序规则.
  104. */
  105. collation?: string;
  106. /**
  107. * 规定可枚举的数据.
  108. */
  109. enum?: any[] | Object;
  110. /**
  111. * 生成的列表达式.
  112. */
  113. asExpression?: string;
  114. /**
  115. * 生成的列类型.
  116. */
  117. generatedType?: "VIRTUAL" | "STORED";
  118. /**
  119. * 返回列类型
  120. */
  121. hstoreType?: "object" | "string";
  122. /**
  123. * 是否数组
  124. */
  125. array?: boolean;
  126. /**
  127. * 转换器
  128. */
  129. transformer?: ValueTransformer;
  130. }
  131. /**
  132. * 列装饰器用于标记特定的类属性作为列。只有在保存实体时,使用该装饰器的属性才会被持久化到数据库中。
  133. */
  134. export declare function Column(): Function;
  135. export declare function Column(options: ColumnOptions): Function;
  136. export declare function Column(type: SimpleColumnType, options?: ColumnCommonOptions): Function;
  137. export declare function Column(type: WithLengthColumnType, options?: ColumnCommonOptions & ColumnWithLengthOptions): Function;
  138. export declare function Column(type: WithWidthColumnType, options?: ColumnCommonOptions & ColumnWithWidthOptions): Function;
  139. export declare function Column(type: WithPrecisionColumnType, options?: ColumnCommonOptions & ColumnNumericOptions): Function;
  140. export declare function Column(type: "enum", options?: ColumnCommonOptions & ColumnEnumOptions): Function;
  141. export declare function Column(type: "hstore", options?: ColumnCommonOptions & ColumnHstoreOptions): Function;
  142. /**
  143. * 实体中的属性可以标记为嵌入式,并且在持久性上,
  144. * 所有来自嵌入式的列都映射到使用嵌入的实体的单个表。
  145. * 在水化过程中,所有被嵌入的列都将从单个表映射到它。
  146. */
  147. export declare function Column(type: (type?: any) => Function, options?: ColumnEmbeddedOptions): Function;
  148. 复制代码

OneToMany

  1. export interface RelationOptions {
  2. /**
  3. * 设置给定关系的级联选项。
  4. * 如果设置为true,则意味着可以允许在数据库中插入或更新相关对象。
  5. * 可以使用以下语法单独限制级联插入或更新:
  6. * cascade: ["insert", "update"]
  7. */
  8. cascade?: boolean | ("insert" | "update" | "remove")[];
  9. /**
  10. * 标示关系列值是否可以为空值。
  11. */
  12. nullable?: boolean;
  13. /**
  14. * 删除数据库时操作.
  15. */
  16. onDelete?: OnDeleteType;
  17. /**
  18. * 更新数据库时操作
  19. */
  20. onUpdate?: OnUpdateType;
  21. /**
  22. * 此关系是否为主键。只能用于多对一和业主一对一的关系
  23. */
  24. primary?: boolean;
  25. /**
  26. * 是否懒加载,当使用时获取
  27. */
  28. lazy?: boolean;
  29. /**
  30. * find查找时,是否自动加载关系,可以设置其中一方
  31. */
  32. eager?: boolean;
  33. /**
  34. * 是否持久性
  35. * 如果其已禁用,则只能更改关系的反面或使用关系查询生成器功能
  36. */
  37. persistence?: boolean;
  38. }
  39. /**
  40. * 一对多
  41. * 如: 一个员工,只能属于一个公司,公司可以有多个员工
  42. * 一是公司 多是员工 type=>员工 员工.公司 string
  43. */
  44. export declare function OneToMany<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide: string | ((object: T) => any), options?: RelationOptions): Function;
  45. 复制代码

ManyToOne

  1. /**
  2. * 多对一
  3. * 一个员工,只能属于一个公司,公司可以有多个员工
  4. * 多是公司,一是员工 type=>公司, 公司.员工 array
  5. */
  6. export declare function ManyToOne<T>(typeFunction: (type?: any) => ObjectType<T>, options?: RelationOptions): Function;
  7. export declare function ManyToOne<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide?: string | ((object: T) => any), options?: RelationOptions): Function;
  8. 复制代码

PrimaryGeneratedColumn

  1. export declare type PrimaryGeneratedColumnType = "int" | "int2" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "numeric" | "number";
  2. /**
  3. * PrimaryGeneratedColumn
  4. */
  5. export interface PrimaryGeneratedColumnNumericOptions {
  6. /**
  7. * 列类型.
  8. */
  9. type?: PrimaryGeneratedColumnType;
  10. /**
  11. * 名称
  12. */
  13. name?: string;
  14. /**
  15. * 备注.
  16. */
  17. comment?: string;
  18. /**
  19. * 是否 zero fill
  20. */
  21. zerofill?: boolean;
  22. /**
  23. * 是否unsigned
  24. */
  25. unsigned?: boolean;
  26. }
  27. export interface PrimaryGeneratedColumnUUIDOptions {
  28. /**
  29. * 名称
  30. */
  31. name?: string;
  32. /**
  33. * 备注.
  34. */
  35. comment?: string;
  36. }
  37. /**
  38. * 主键自增
  39. */
  40. export declare function PrimaryGeneratedColumn(): Function;
  41. /**
  42. * 主键自增
  43. */
  44. export declare function PrimaryGeneratedColumn(options: PrimaryGeneratedColumnNumericOptions): Function;
  45. /**
  46. * 主键自增
  47. */
  48. export declare function PrimaryGeneratedColumn(strategy: "increment", options?: PrimaryGeneratedColumnNumericOptions): Function;
  49. /**
  50. * 主键uuid模式
  51. */
  52. export declare function PrimaryGeneratedColumn(strategy: "uuid", options?: PrimaryGeneratedColumnUUIDOptions): Function;
  53. 复制代码

PrimaryColumn

  1. /**
  2. * PRIMARY KEY
  3. */
  4. export declare function PrimaryColumn(options?: ColumnOptions): Function;
  5. /**
  6. * PRIMARY KEY
  7. */
  8. export declare function PrimaryColumn(type?: ColumnType, options?: ColumnOptions): Function;
  9. 复制代码

UpdateDateColumn

  1. // 更新日期
  2. export declare function UpdateDateColumn(options?: ColumnOptions): Function;
  3. 复制代码

CreateDateColumn

  1. // 插入日期
  2. export declare function CreateDateColumn(options?: ColumnOptions): Function;
  3. 复制代码

VersionColumn

  1. // 数字版本
  2. export declare function VersionColumn(options?: ColumnOptions): Function;
  3. 复制代码

AfterInsert

  1. // 插入后执行脚本
  2. export declare function AfterInsert(): (object: Object, propertyName: string) => void;
  3. 复制代码

AfterLoad

  1. // 加载后钩子
  2. export declare function AfterLoad(): (object: Object, propertyName: string) => void;
  3. 复制代码

AfterRemove

  1. // remove后钩子
  2. export declare function AfterRemove(): (object: Object, propertyName: string) => void;
  3. 复制代码

AfterUpdate

  1. // 更新钩子
  2. export declare function AfterUpdate(): (object: Object, propertyName: string) => void;
  3. 复制代码

BeforeInsert

  1. // insert前
  2. export declare function BeforeInsert(): (object: Object, propertyName: string) => void;
  3. 复制代码

BeforeRemove

  1. // remove前
  2. export declare function BeforeRemove(): (object: Object, propertyName: string) => void;
  3. 复制代码

BeforeUpdate

  1. // 更新前
  2. export declare function BeforeUpdate(): (object: Object, propertyName: string) => void;
  3. 复制代码

EventSubscriber

  1. // 事件监听
  2. export declare function EventSubscriber(): (target: Function) => void;
  3. 复制代码

JoinColumn

  1. export interface JoinColumnOptions {
  2. /**
  3. * 名称
  4. */
  5. name?: string;
  6. /**
  7. * 引用该列的实体中列的名称
  8. */
  9. referencedColumnName?: string;
  10. }
  11. /**
  12. * 一对一或多对一关系指定
  13. */
  14. export declare function JoinColumn(): Function;
  15. export declare function JoinColumn(options: JoinColumnOptions): Function;
  16. export declare function JoinColumn(options: JoinColumnOptions[]): Function;
  17. 复制代码

JoinTable

  1. export interface JoinColumnOptions {
  2. /**
  3. * 自定义名称
  4. */
  5. name?: string;
  6. /**
  7. * 列名称
  8. */
  9. referencedColumnName?: string;
  10. }
  11. /**
  12. * Describes join table options.
  13. */
  14. export interface JoinTableOptions {
  15. /**
  16. * 名称
  17. */
  18. name?: string;
  19. /**
  20. * 连接表的第一列
  21. */
  22. joinColumn?: JoinColumnOptions;
  23. /**
  24. * 连接表的第二列
  25. */
  26. inverseJoinColumn?: JoinColumnOptions;
  27. /**
  28. * 表明
  29. */
  30. database?: string;
  31. /**
  32. * 创建连接表schema
  33. */
  34. schema?: string;
  35. }
  36. export interface JoinTableMultipleColumnsOptions {
  37. /**
  38. * 连接表值得表名称,默认自动创建
  39. */
  40. name?: string;
  41. /**
  42. * 连接表的第一列
  43. */
  44. joinColumns?: JoinColumnOptions[];
  45. /**
  46. * 连接表的第二列
  47. */
  48. inverseJoinColumns?: JoinColumnOptions[];
  49. /**
  50. * 数据库
  51. */
  52. database?: string;
  53. /**
  54. * schema
  55. */
  56. schema?: string;
  57. }
  58. /**
  59. * 多对多关系
  60. */
  61. export declare function JoinTable(): Function;
  62. export declare function JoinTable(options: JoinTableOptions): Function;
  63. export declare function JoinTable(options: JoinTableMultipleColumnsOptions): Function;
  64. 复制代码

ManyToMany

  1. export interface RelationOptions {
  2. /**
  3. * cascade
  4. */
  5. cascade?: boolean | ("insert" | "update" | "remove")[];
  6. /**
  7. * 是否可以null.
  8. */
  9. nullable?: boolean;
  10. /**
  11. * 删除时
  12. */
  13. onDelete?: OnDeleteType;
  14. /**
  15. * 更新时
  16. */
  17. onUpdate?: OnUpdateType;
  18. /**
  19. * 主键
  20. */
  21. primary?: boolean;
  22. /**
  23. * 惰性加载
  24. */
  25. lazy?: boolean;
  26. /**
  27. * eager
  28. */
  29. eager?: boolean;
  30. /**
  31. * persistence
  32. */
  33. persistence?: boolean;
  34. }
  35. /**
  36. * 多对多关系,这种类型的关系创建一个连接表,用于保存关系数据
  37. */
  38. export declare function ManyToMany<T>(typeFunction: (type?: any) => ObjectType<T>, options?: RelationOptions): Function;
  39. export declare function ManyToMany<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide?: string | ((object: T) => any), options?: RelationOptions): Function;
  40. 复制代码

ManyToOne

  1. // 多对一
  2. export declare function ManyToOne<T>(typeFunction: (type?: any) => ObjectType<T>, options?: RelationOptions): Function;
  3. export declare function ManyToOne<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide?: string | ((object: T) => any), options?: RelationOptions): Function;
  4. 复制代码

OneToMany

  1. // 一对多
  2. export declare function OneToMany<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide: string | ((object: T) => any), options?: RelationOptions): Function;
  3. 复制代码

OneToOne

  1. /**
  2. * 一对一
  3. */
  4. export declare function OneToOne<T>(typeFunction: (type?: any) => ObjectType<T>, options?: RelationOptions): Function;
  5. export declare function OneToOne<T>(typeFunction: (type?: any) => ObjectType<T>, inverseSide?: string | ((object: T) => any), options?: RelationOptions): Function;
  6. 复制代码

RelationCount

  1. // 数量
  2. export declare function RelationCount<T>(relation: string | ((object: T) => any), alias?: string, queryBuilderFactory?: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>): Function;
  3. 复制代码

RelationId

  1. // 提取id
  2. export declare function RelationId<T>(relation: string | ((object: T) => any), alias?: string, queryBuilderFactory?: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>): Function;
  3. 复制代码
Tree
Tree
TreeParent
TreeLevelColumn
TreeChildren
  1. /**
  2. * 标记实体像树一样工作。
  3. * 应该指定树实体的树模式。
  4. * @TreeParent
  5. */
  6. export declare function Tree(type: TreeType): Function;
  7. export declare function TreeParent(): Function;
  8. export declare function TreeLevelColumn(): Function;
  9. export declare function TreeChildren(options?: {
  10. cascade?: boolean | ("insert" | "update" | "remove")[];
  11. }): Function;
  12. 复制代码
Transaction
Transaction
TransactionRepository
TransactionManager
  1. /**
  2. * 将一些方法封装成事务.
  3. *
  4. * 如果想要使用实体管理器
  5. * then use @TransactionEntityManager() decorator.
  6. *
  7. * 如果想要使用存储库
  8. * then use @TransactionRepository() decorator.
  9. */
  10. export declare function Transaction(connectionName?: string): MethodDecorator;
  11. /**
  12. * 事物存储库
  13. */
  14. export declare function TransactionRepository(entityType?: Function): ParameterDecorator;
  15. /**
  16. * 事物实体管理器
  17. */
  18. export declare function TransactionManager(): Function;
  19. 复制代码
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/661390
推荐阅读
  

闽ICP备14008679号