103 lines
3.3 KiB
Plaintext
103 lines
3.3 KiB
Plaintext
|
|
|
|
/* TableMetadata object represents a table.
|
|
This is the object returned in the getTable() callback.
|
|
indexes[0] will *ALWAYS* represent the intrinsic primary key.
|
|
*/
|
|
TableMetadata = {
|
|
database : "", // Database name
|
|
name : "", // Table Name
|
|
columns : {}, // ordered array of ColumnMetadata objects
|
|
indexes : {}, // array of IndexMetadata objects
|
|
foreignKeys : {}, // array of ForeignKeyMetadata objects
|
|
partitionKey : {}, // ordered array of column numbers in the partition key
|
|
};
|
|
|
|
|
|
/* ColumnMetadata object represents a column.
|
|
*/
|
|
ColumnMetadata = {
|
|
/* Required Properties */
|
|
name : "" , // column name
|
|
columnNumber : -1 , // position of column in table, and in columns array
|
|
columnType : "" , // a ColumnType
|
|
isIntegral : false, // true if column is some variety of INTEGER type
|
|
isNullable : false, // true if NULLABLE
|
|
isInPrimaryKey : false, // true if column is part of PK
|
|
isInPartitionKey : false, // true if column is part of partition key
|
|
columnSpace : 0 , // buffer space required for encoded stored value
|
|
defaultValue : null , // default value for column: null for default NULL;
|
|
// undefined for no default; or a type-appropriate
|
|
// value for column
|
|
|
|
/* Optional Properties, depending on columnType */
|
|
/* Group A: Numeric */
|
|
isUnsigned : false, // true for UNSIGNED
|
|
intSize : null , // 1,2,3,4, or 8 if column type is INT
|
|
scale : 0 , // DECIMAL scale
|
|
precision : 0 , // DECIMAL precision
|
|
isAutoincrement : false, // true for AUTO_INCREMENT columns
|
|
|
|
/* Group B: Non-numeric */
|
|
length : 0 , // CHAR or VARCHAR length in characters
|
|
isBinary : false, // true for BLOB/BINARY/VARBINARY
|
|
charsetName : "" , // name of charset
|
|
};
|
|
|
|
|
|
/* IndexMetadata represents a table index.
|
|
|
|
The "indexes" array of TableMetadata will hold one or two IndexMetadata
|
|
records per table index. For an index that is both unique and ordered, two
|
|
records are created, one with the isUnique flag set, and the other with the
|
|
isOrdered flag set.
|
|
*/
|
|
IndexMetadata = {
|
|
name : "" , // Index name; undefined for PK
|
|
isPrimaryKey : true , // true for PK; otherwise undefined
|
|
isUnique : true , // true or false
|
|
isOrdered : true , // true or false; can scan if true
|
|
columnNumbers : null , // an ordered array of column numbers
|
|
};
|
|
|
|
|
|
/* ForeignKeyMetadata represents a foreign key constraint.
|
|
|
|
The "foreignKeys" array of TableMetadata will hold the foreign key constraints.
|
|
|
|
*/
|
|
ForeignKeyMetadata = {
|
|
name : "" , // Constraint name
|
|
columnNames : null , // an ordered array of column numbers
|
|
targetTable : "" , // referenced table name
|
|
targetDatabase : "" , // referenced database
|
|
targetColumnNames: null , // an ordered array of target column names
|
|
};
|
|
|
|
|
|
ColumnTypes = [
|
|
"TINYINT",
|
|
"SMALLINT",
|
|
"MEDIUMINT",
|
|
"INT",
|
|
"BIGINT",
|
|
"FLOAT",
|
|
"DOUBLE",
|
|
"DECIMAL",
|
|
"CHAR",
|
|
"VARCHAR",
|
|
"BLOB",
|
|
"TEXT",
|
|
"DATE",
|
|
"TIME",
|
|
"DATETIME",
|
|
"YEAR",
|
|
"TIMESTAMP",
|
|
"BIT",
|
|
"BINARY",
|
|
"VARBINARY"
|
|
];
|
|
|
|
|
|
exports.ColumnTypes = ColumnTypes;
|