MySQL NDB Cluster API 开发人员指南 / 第 5 章用于 JavaScript 的 MySQL NoSQL 连接器 / 5.3 JavaScript API 文档的连接器 /
5.3.9 表元数据
一个TableMetadata
对象代表一个表。这是getTable()
回调中返回的对象。indexes[0]
代表表的内在主键。
Press CTRL+C to copyTableMetadata = { database : "" , // Database name name : "" , // Table Name columns : {} , // ordered array of ColumnMetadata objects indexes : {} , // array of IndexMetadata objects partitionKey : {} , // ordered array of column numbers in the partition key };
ColumnMetadata
object 表示表列。
Press CTRL+C to copyColumnMetadata = { /* Required Properties */ name : "" , // column name columnNumber : -1 , // position of column in table, and in columns array columnType : "" , // a ColumnTypes value 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 charsetNumber : 0 , // internal number of charset charsetName : "" , // name of charset };
一个IndexMetadata
对象代表一个表索引。每个表索引
包含一个
对象的indexes
数组
。TableMetadata
IndexMetadata
NDB
将主键实现为有序索引和唯一索引,并且可以通过 NDB API 适配器将其视为两个索引,但通过 MySQL 适配器将其视为既唯一又有序的单个索引。我们容忍这种差异,并注意到中的实现
Adapter/api
必须将这两个描述视为等同的。
Press CTRL+C to copyIndexMetadata = { 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 columns : null , // an ordered array of column numbers };
ColumnMetaData
对象的
必须columnType
是有效值
ColumnTypes
,如此处对象的定义所示:
Press CTRL+C to copyColumnTypes = [ "TINYINT", "SMALLINT", "MEDIUMINT", "INT", "BIGINT", "FLOAT", "DOUBLE", "DECIMAL", "CHAR", "VARCHAR", "BLOB", "TEXT", "DATE", "TIME", "DATETIME", "YEAR", "TIMESTAMP", "BIT", "BINARY", "VARBINARY" ];