5.3.9 TableMetadata

A TableMetadata object represents a table. This is the object returned in the getTable() callback. indexes[0] represents the table's intrinsic primary key.

TableMetadata = {
  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 represents a table column.

ColumnMetadata = {
  /* 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
};

An IndexMetadata object represents a table index. The indexes array of TableMetadata contains one IndexMetadata object per table index.

NDB implements a primary key as both an ordered index and a unique index, and might be viewed through the NDB API adapter as two indexes, but through a MySQL adapter as a single index that is both unique and ordered. We tolerate this discrepancy and note that the implementation in Adapter/api must treat the two descriptions as equivalent.

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
  columns          : null  ,  // an ordered array of column numbers
};

The ColumnMetaData object's columnType must be a valid ColumnTypes value, as shown in this object's definition here:

ColumnTypes =  [
  "TINYINT",
  "SMALLINT",
  "MEDIUMINT",
  "INT",
  "BIGINT",
  "FLOAT",
  "DOUBLE",
  "DECIMAL",
  "CHAR",
  "VARCHAR",
  "BLOB",
  "TEXT",
  "DATE",
  "TIME",
  "DATETIME",
  "YEAR",
  "TIMESTAMP",
  "BIT",
  "BINARY",
  "VARBINARY"
];