typeorm列タイプ

5706 ワード

//         ,     、       
export type PrimaryGeneratedColumnType = "int" // mysql, mssql, oracle, sqlite
    |"int2" // postgres, sqlite
    |"int2" // postgres, sqlite
    |"int4" // postgres
    |"int8" // postgres, sqlite
    |"integer" // postgres, oracle, sqlite
    |"tinyint" // mysql, mssql, sqlite
    |"smallint" // mysql, postgres, mssql, oracle, sqlite
    |"mediumint" // mysql, sqlite
    |"bigint" // mysql, postgres, mssql, sqlite
    |"dec" // oracle, mssql
    |"decimal" // mysql, postgres, mssql, sqlite
    |"numeric" // postgres, mssql, sqlite
    |"number"; // oracle

//        ,        、    
export type WithPrecisionColumnType = "float" // mysql, mssql, oracle, sqlite
    |"double" // mysql, sqlite
    |"dec" // oracle, mssql
    |"decimal" // mysql, postgres, mssql, sqlite
    |"numeric" // postgres, mssql, sqlite
    |"real" // mysql, postgres, mssql, oracle, sqlite
    |"double precision" // postgres, oracle, sqlite
    |"number" // oracle
    |"datetime" // mssql, mysql, sqlite
    |"datetime2" // mssql
    |"datetimeoffset" // mssql
    |"time" // mysql, postgres, mssql
    |"time with time zone" // postgres
    |"time without time zone" // postgres
    |"timestamp" // mysql, postgres, mssql, oracle
    |"timestamp without time zone" // postgres
    |"timestamp with time zone"; // postgres, oracle

//        ,
export type WithLengthColumnType = "int" // mysql, postgres, mssql, oracle, sqlite
    |"tinyint" // mysql, mssql, sqlite
    |"smallint" // mysql, postgres, mssql, oracle, sqlite
    |"mediumint" // mysql, sqlite
    |"bigint" // mysql, postgres, mssql, sqlite
    |"character varying" // postgres
    |"varying character" // sqlite
    |"nvarchar" // mssql
    |"character" // mysql, postgres, sqlite
    |"native character" // sqlite
    |"varchar" // mysql, postgres, mssql, sqlite
    |"char" // mysql, postgres, mssql, oracle
    |"nchar" // mssql, oracle, sqlite
    |"varchar2" // oracle
    |"nvarchar2" // oracle, sqlite
    |"binary" // mssql
    |"varbinary"; // mssql

//     
export type SimpleColumnType =
    //    , typeorm  ,      string  
    "simple-array" // typeorm-specific, automatically mapped to string
    //string  ,      varchar  
    |"string" // typeorm-specific, automatically mapped to varchar depend on platform
    //    
    |"bit" // mssql
    |"int2" // postgres, sqlite
    |"integer" // postgres, oracle, sqlite
    |"int4" // postgres
    |"int8" // postgres, sqlite
    |"unsigned big int" // sqlite
    |"float4" // postgres
    |"float8" // postgres
    |"smallmoney" // mssql
    |"money" // postgres, mssql

    //boolean  
    |"boolean" // postgres, sqlite
    |"bool" // postgres

    //   、    
    |"tinyblob" // mysql
    |"tinytext" // mysql
    |"mediumblob" // mysql
    |"mediumtext" // mysql
    |"blob" // mysql, oracle, sqlite
    |"text" // mysql, postgres, mssql, sqlite
    |"ntext" // mssql
    |"citext" // postgres
    |"longblob" // mysql
    |"longtext" // mysql
    |"bytea" // postgres
    |"long" // oracle
    |"raw" // oracle
    |"long raw" // oracle
    |"bfile" // oracle
    |"clob" // oracle, sqlite
    |"nclob" // oracle
    |"image" // mssql

    //    
    |"timestamp with local time zone" // oracle
    |"smalldatetime" // mssql
    |"date" // mysql, postgres, mssql, oracle, sqlite
    |"interval year" // oracle
    |"interval day" // oracle
    |"interval" // postgres
    |"year" // mysql

    //    ,  postgres  
    |"point" // postgres
    |"line" // postgres
    |"lseg" // postgres
    |"box" // postgres
    |"circle" // postgres
    |"path" // postgres
    |"polygon" // postgres

    // other types
    |"enum" // mysql, postgres
    |"cidr" // postgres
    |"inet" // postgres
    |"macaddr"// postgres
    |"bit" // postgres
    |"bit varying" // postgres
    |"varbit"// postgres
    |"tsvector" // postgres
    |"tsquery" // postgres
    |"uuid" // postgres
    |"xml" // mssql, postgres
    |"json" // mysql, postgres
    |"jsonb" // postgres
    |"varbinary" // mssql
    |"cursor" // mssql
    |"hierarchyid" // mssql
    |"sql_variant" // mssql
    |"table" // mssql
    |"rowid" // oracle
    |"urowid" // oracle
    |"uniqueidentifier"; // mssql

//     ,     ,           
export type ColumnType = 
    //      
    WithPrecisionColumnType
    //      
    |WithLengthColumnType
    //    
    |SimpleColumnType
    //boolean  
    |BooleanConstructor
    //Date  
    |DateConstructor
    //    
    |NumberConstructor
    //     
    |StringConstructor;


コンビネーションクラスColumnTypeはコンビネーションタイプであり、長さタイプ、精度タイプ、単純タイプなどがコンビネーションされており、これらのタイプの間には重複部分があり、主に装飾パラメータタイプを区別するためであることがわかる.
注目すべきはsimple-arrayタイプのみです.typeorm固有のタイプです.つまり、エンティティ属性は配列であり、データベースにカンマで区切られた文字列に格納できます.