initClients

Initializes the connector for use. This is similar to connect(), but stops short of actually connecting to the server.

initClients(): DbCon
Returns
DbCon: Object.

connectAsync

Create a connection to the MapD server, generating a client and session ID.

connectAsync(): Promise.DbCon
Returns
Promise.DbCon: Object.
Example

Connect to a MapD server:

var con = new DbCon()
  .host('localhost')
  .port('8080')
  .dbName('myDatabase')
  .user('foo')
  .password('bar')
  .connect()
  .then((con) => console.log(con.sessionId()));

  // ["om9E9Ujgbhl6wIzWgLENncjWsaXRDYLy"]

connect

Create a connection to the MapD server, generating a client and session ID.

connect
Parameters
callback (Function) An optional callback that takes (err, success) as its signature. Returns con singleton if successful.
Returns
Promise.DbCon: Object.
Example

Connect to a MapD server:

var con = new DbCon()
  .host('localhost')
  .port('8080')
  .dbName('myDatabase')
  .user('foo')
  .password('bar')
  .connect((err, con) => console.log(con.sessionId()));

  // ["om9E9Ujgbhl6wIzWgLENncjWsaXRDYLy"]

disconnectAsync

Disconnect from the server and then clear the client and session values.

disconnectAsync
Returns
Promise.DbCon: Object.
Example

Disconnect from the server:

con.disconnect()

disconnect

Disconnect from the server and then clear the client and session values.

disconnect
Parameters
callback (Function) An optional callback that takes (err, success) as its signature. Returns con singleton if successful.
Returns
Promise.DbCon: Object.
Example

Disconnect from the server:

con.sessionId() // ["om9E9Ujgbhl6wIzWgLENncjWsaXRDYLy"]
con.disconnect((err, con) => console.log(err, con))
con.sessionId() === null;

getStatusAsync

Get the status of the server as a TServerStatus object. This includes the server version number, whether the server is read-only, and whether backend rendering is enabled.

getStatusAsync
Returns
Promise<Object>: An object that contains information about the server status.
Example

Get the server status:

con.getStatusAsync().then((result) => console.log(result))
// [{
//   "read_only": false,
//   "version": "3.0.0dev-20170503-40e2de3",
//   "rendering_enabled": true,
//   "start_time": 1493840131
// }]

getStatus

Get the status of the server as a TServerStatus object. This includes the server version number, whether the server is read-only, and whether backend rendering is enabled.

getStatus
Parameters
callback (Function) An optional callback that takes (err, success) as its signature. Returns an object that contains information about the server status.
Returns
Promise<Object>: An object that contains information about the server status.
Example

Get the server status:

con.getStatus((err, result) => console.log(result))
// [{
//   "read_only": false,
//   "version": "3.0.0dev-20170503-40e2de3",
//   "rendering_enabled": true,
//   "start_time": 1493840131
// }]

getHardwareInfoAsync

Get information about the server hardware:

  • Number of GPUs.
  • Number of GPUs allocated to MapD.
  • Start GPU.
  • Number of SMs, SMXs, or CUs (streaming multiprocessors).
  • Clock frequency of each GPU.
  • Physical memory of each GPU.
  • Compute capability of each GPU.
getHardwareInfoAsync
Returns
Promise<Object>: An object that contains hardware information.
Example

Get server hardware information:

con.getHardwareInfoAsync().then((result) => console.log(result))
{
  "hardware_info": [{
   "num_gpu_hw": 2,
     "num_cpu_hw": 12,
     "num_gpu_allocated": 2,
     "start_gpu": 0,
     "host_name": "",
     "gpu_info": [{
         "num_sm": 28,
         "clock_frequency_kHz": 1531000,
         "memory": 12781682688,
         "compute_capability_major": 6,
         "compute_capability_minor": 1
     }, {
         "num_sm": 28,
         "clock_frequency_kHz": 1531000,
         "memory": 12782075904,
         "compute_capability_major": 6,
         "compute_capability_minor": 1
     }]
  }]
}

getHardwareInfo

Get information about the server hardware:

  • Number of GPUs.
  • Number of GPUs allocated to MapD.
  • Start GPU.
  • Number of SMs, SMXs, or CUs (streaming multiprocessors).
  • Clock frequency of each GPU.
  • Physical memory of each GPU.
  • Compute capability of each GPU.
getHardwareInfo
Parameters
callback (Function) An optional callback that takes (err, success) as its signature. Returns an object that contains hardware information.
Returns
Promise<Object>: An object that contains hardware information.
Example

Get server hardware information:

con.getHardwareInfo((err, result) => console.log(result))
{
  "hardware_info": [{
   "num_gpu_hw": 2,
     "num_cpu_hw": 12,
     "num_gpu_allocated": 2,
     "start_gpu": 0,
     "host_name": "",
     "gpu_info": [{
         "num_sm": 28,
         "clock_frequency_kHz": 1531000,
         "memory": 12781682688,
         "compute_capability_major": 6,
         "compute_capability_minor": 1
     }, {
         "num_sm": 28,
         "clock_frequency_kHz": 1531000,
         "memory": 12782075904,
         "compute_capability_major": 6,
         "compute_capability_minor": 1
     }]
  }]
}

getFirstGeoFileInArchiveAsync

Get the first geo file in an archive, if present, to determine if the archive should be treated as geo.

getFirstGeoFileInArchiveAsync
Parameters
archivePath (String) The base filename of the archive.
copyParams (TCopyParams) See TCopyParams
Returns
Promise<String>: Full path to the located geo file; otherwise, to the original archivePath.
Example

Get the first geo file in an archive:

con.getFirstGeoFileInArchiveAsync('archive.zip', {}).then(res => console.log(res))

getFilesInArchiveAsync

Gets a list of filenames found within an archive.

getFilesInArchiveAsync
Parameters
archivePath (String) The base filename of the archive.
copyParams (TCopyParams) See TCopyParams
Returns
Promise<Array>: A list of filenames (strings)
Example

Get the filenames found within an archive:

con.getFilesInArchiveAsync('archive.zip', {}).then(res => console.log(res))

getUsersAsync

Get a list of all users on the database for this connection.

getUsersAsync
Returns
Promise<Array>: A list of all users (strings).
Example

Get a list of all users:

con.getUsersAsync().then(res => console.log(res))

getRolesAsync

Get a list of all roles on the database for this connection.

getRolesAsync
Returns
Promise<Array>: A list of all roles (strings).
Example

Get a list of all roles:

con.getRolesAsync().then(res => console.log(res))

getDashboardsAsync

Get a list of all dashboards on the database for this connection.

getDashboardsAsync
Returns
Promise<Array<TDashboard>>: A list of all dashboards (Dashboard objects).
Example

Get a list of all dashboards:

con.getDashboardsAsync().then(res => console.log(res))

getDashboardAsync

Get a single dashboard.

getDashboardAsync
Parameters
dashboardId (Number) The ID of the dashboard.
Returns
Promise<TDashboard>: The dashboard (Dashboard object).
Example

Get a dashboard:

con.getDashboardAsync().then(res => console.log(res))

createDashboardAsync

Add a new dashboard to the server.

createDashboardAsync
Parameters
dashboardName (String) The name of the new dashboard.
dashboardState (String) The Base64-encoded state string of the new dashboard.
imageHash (String) The numeric hash of the dashboard thumbnail.
metaData (String) Stringified metadata related to the view.
Returns
Promise: Returns a Promise.all result (array) of the IDs created on each client.
Example

Add a new dashboard to the server:

con.createDashboardAsync('newSave', 'dashboardstateBase64', null, 'metaData').then(res => console.log(res))

replaceDashboardAsync

Replace a dashboard on the server with new properties.

replaceDashboardAsync
Parameters
dashboardId (Number) The ID of the dashboard to replace.
dashboardName (String) The name of the new dashboard.
dashboardOwner (String) User ID of the owner of the dashboard.
dashboardState (String) The Base64-encoded state string of the new dashboard.
imageHash (String) The numeric hash of the dashboard thumbnail.
metaData (String) Stringified metadata related to the view.
Returns
Promise: Returns empty if successful, rejects if any client failed.
Example

Replace a dashboard on the server:

con.replaceDashboardAsync(123, 'replaceSave', 'owner', 'dashboardstateBase64', null, 'metaData').then(res => console.log(res))

deleteDashboardAsync

Delete a dashboard object containing a value for the view_state property.

deleteDashboardAsync
Parameters
dashboardId (Number) The ID of the dashboard.
Returns
Promise: Returns empty if successful, rejects if any client failed.
Example

Delete a specific dashboard from the server:

con.deleteDashboardAsync(123).then(res => console.log(res))

deleteDashboardsAsync

Delete multiple dashboards

deleteDashboardsAsync
Parameters
dashboardIds (Array) An array of dashboard ids (numbers)
Returns
Promise: Returns empty if successful, rejects if any client failed.
Example

Delete dashboards from the server:

con.deleteDashboardsAsync([123, 456]).then(res => console.log(res))

shareDashboardAsync

Share a dashboard (GRANT a certain set of permissions to a specified list of groups).

shareDashboardAsync
Parameters
dashboardId (Number) The ID of the dashboard.
groups (Array<String>) The roles and users that can access the dashboard.
objects (Array<String>) The database objects (tables) that groups can see.
permissions (Array<String>) Permissions granted to the groups.
Returns
Promise: Returns empty if successful.
Example

Share a dashboard:

con.shareDashboardAsync(123, ['group1', 'group2'], ['object1', 'object2'], ['perm1', 'perm2']).then(res => console.log(res))

shareDashboardsAsync

Share multiple dashboards.

shareDashboardsAsync
Parameters
dashboardIds (Array) An array of dashboard ids (numbers)
groups (Array<String>) The roles and users that can access the dashboard.
permissions (Array<String>) Permissions granted to the groups.
Returns
Promise: Returns empty if successful.
Example

Share dashboards:

con.shareDashboardsAsync([123, 456], ['group1', 'group2'], ['perm1', 'perm2']).then(res => console.log(res))

unshareDashboardAsync

Stop sharing a dashboard (REVOKE a certain set of permission from a specified list of groups).

unshareDashboardAsync
Parameters
dashboardId (Number) The ID of the dashboard.
groups (Array<String>) The roles and users that can access it.
objects (Array<String>) The database objects (tables) that groups can see.
permissions (Array<String>) Permissions revoked from the groups.
Returns
Promise: Returns empty if successful.
Example

Unshare a dashboard:

con.unshareDashboardAsync(123, ['group1', 'group2'], ['object1', 'object2'], ['perm1', 'perm2']).then(res => console.log(res))

unshareDashboardsAsync

Unshare multiple dashboards.

unshareDashboardsAsync
Parameters
dashboardIds (Array<Number>) An array of dashboard ids
groups (Array<String>) The roles and users to unshare with.
permissions (Array<String>) The permissions to remove.
Returns
Promise: Returns empty if successful.
Example

Unshare dashboards:

con.unshareDashboardsAsync([123, 456], ['group1', 'group2'], ['perm1', 'perm2']).then(res => console.log(res))

getDashboardGranteesAsync

Get the list of users that a dashboard has been shared with; that is, those users who have been granted permissions to the dashboard.

getDashboardGranteesAsync
Parameters
dashboardId (Number) The ID of the dashboard.
Returns
Promise: Returns the list of users (array).
Example

Get the list of grantees for a dashboard:

con.getDashboardGranteesAsync(123).then(res => console.log(res))

getDbObjectsForGranteeAsync

Get a list of database objects granted to a role; that is, those objects the role has permissions to access.

getDbObjectsForGranteeAsync
Parameters
roleName (String) The name of the role.
Returns
Promise: Returns the list of database object names (strings).
Example

Get list of accessible database objects for a role:

con.getDbObjectsForGranteeAsync('role').then(res => console.log(res))

getDbObjectPrivsAsync

Get the privileges for the current user for a specified database object type and ID.

getDbObjectPrivsAsync
Parameters
objectName (String) The ID of the object (e.g. table name or dashboard ID).
type (TDBObjectType) The type of the database object.
Returns
Promise<Array<TDBObject>>: Returns the list of database objects for this type and ID, including their privs (property 'privs').
Example

Get the list of accessible database objects for the current user:

con.getDbObjectPrivsAsync('table_name', 'TableDBObjectType').then(res => console.log(res))

getAllRolesForUserAsync

Get all the roles assigned directly to a given username.

getAllRolesForUserAsync
Parameters
username (String) The username whose roles you wish to get.
Returns
Promise: A list of all roles assigned to the username.

getAllEffectiveRolesForUserAsync

Get all the roles assigned to a given username recursively (ie, roles assigned to the user, and roles assigned to those roles, and so on).

getAllEffectiveRolesForUserAsync
Parameters
username (String) The username whose roles you wish to get.
Returns
Promise: A list of all roles assigned to the username.

hasObjectPrivilegesAsync

Checks if the given user or role has a privilege(s) on a given object. Note that this check is transative; if a user has been granted a privilege via a role, this will return true.

hasObjectPrivilegesAsync
Parameters
granteeName (String) The name of the user or role to check privileges for.
objectName (String) The name of the object to check privileges against (for example, the database name, table name, etc.)
objectType (TDBObjectType) The type of object to check privileges against.
permissions (TDBObjectPermissions) An object containing the privileges to check. All the privileges specified must be granted for this function to return true.
Returns
Boolean: true if all the specified privileges have been granted to the user/role, false otherwise.
Example

Check if user my_user has the "view SQL Editor" privilege on the my_db database:

con.hasDbPrivilegesAsync(
  "my_user",
  "my_db",
  TDBObjectType.DatabaseDBObjectType,
  new TDBObjectPermissions({
    database_permissions_: new TDatabasePermissions(dbPrivs)
  })
).then((res) =>
  if(res) { console.log("Can view the SQL editor") }
)

hasDbPrivilegesAsync

Specialization of has_object_privilege for checking database privileges of a user.

hasDbPrivilegesAsync
Parameters
granteeName (String) The name of the user or role to check privileges for.
dbName (String) The name of the database to check user privileges against.
dbPrivs (TDatabasePermissions) An object specifying what privileges to check.
Returns
Boolean: true if the user/role has all the specified DB privileges, false otherwise.
Example

Check if user my_user has the "view SQL Editor" privilege on the my_db database:

con.hasDbPrivilegesAsync("my_user", "my_db", {view_sql_editor_: true}).then(res =>
 if(res) { console.log("Can view the SQL editor") }
)

detectColumnTypesAsync

Asynchronously get data from an importable file, such as a CSV or plaintext file with a header.

detectColumnTypesAsync
Parameters
fileName (String) The name of the importable file.
copyParams (TCopyParams) See TCopyParams
Returns
Promise<TDetectResult>: An object that has copy_params and row_set .
Example

Get data from table_data.csv:

var copyParams = new TCopyParams();
con.detectColumnTypesAsync('table_data.csv', copyParams).then(res => console.log(res))
// TDetectResult {row_set: TRowSet, copy_params: TCopyParams}

queryAsync

Submit a query to the database and process the results.

queryAsync
Parameters
query (String) The query to perform.
options (Object) Options for the query.
Returns
Promise.Object: The result of the query.
Example

Create a query:

var query = "SELECT count(*) AS n FROM tweets_nov_feb WHERE country='CO'";
var options = {};

con.query(query, options).then((result) => console.log(result));

query

Submit a query to the database and process the results.

query
Parameters
query (String) The query to perform.
options (Object) Options for the query.
callback (Function) An optional callback function with the signature (err, result) => result .
Returns
Promise.Object: The result of the query.
Example

Create a query:

var query = "SELECT count(*) AS n FROM tweets_nov_feb WHERE country='CO'";
var options = {};

con.query(query, options, function(err, result) {
       console.log(result)
     });

validateQuery

Submit a query to validate that the backend can create a result set based on the SQL statement.

validateQuery
Parameters
query (String) The query to perform.
Returns
Promise<Object>: The result of whether the query is valid.
Example

Create a query and determine if it is valid:

var query = "SELECT count(*) AS n FROM tweets_nov_feb WHERE country='CO'";

con.validateQuery(query).then(res => console.log(res))

// [{
//    "name": "n",
//    "type": "INT",
//    "is_array": false,
//    "is_dict": false
//  }]

getTablesAsync

Get the names of the databases that exist in the current session connection.

getTablesAsync
Returns
Promise<Array<Object>>: List of table objects containing the label and table names.
Example

Get the list of tables from a connection:

con.getTablesAsync().then(res => console.log(res))

 //  [{
 //    label: 'obs', // deprecated property
 //    name: 'myTableName'
 //   },
 //  ...]

getTables

Get the names of the databases that exist in the current session connection.

getTables
Parameters
callback (Function) An optional callback function with the signature (err, result) => result .
Returns
Promise<Array<Object>>: List of table objects containing the label and table names.
Example

Get the list of tables from a connection:

con.getTablesAsync((err, res) => console.log(res))

 //  [{
 //    label: 'obs', // deprecated property
 //    name: 'myTableName'
 //   },
 //  ...]

getTablesWithMetaAsync

Get names and catalog metadata for tables that exist on the current session's connection.

getTablesWithMetaAsync
Returns
Promise<Array<Object>>: The list of objects containing table metadata.
Example

Get the list of tables with metadata from a connection:

con.getTablesWithMetaAsync().then(res => console.log(res))

 [
  {
   name: 'my_table_name',
   col_datum_types: [TDatumType::BOOL, TDatumType::DOUBLE],
   is_view: false,
   is_replicated: false,
   shard_count: 0,
   max_rows: -1
  },
 ...]

getTablesMetaAsync

Get names and catalog metadata for tables that exist on the current session's connection.

getTablesMetaAsync
Returns
Promise<Array<TTableMeta>>: The list of objects containing table metadata.
Example

Get the list of tables with metadata from a connection:

con.getTablesMetaAsync().then(res => console.log(res))

 [
  {
   table_name: 'my_table_name',
   col_datum_types: [TDatumType::BOOL, TDatumType::DOUBLE],
   col_names: ['bool_col', 'double_col'],
   is_view: false,
   is_replicated: false,
   shard_count: 0,
   max_rows: -1
  },
 ...]

getTableFunctionNamesAsync

Returns a list of available table function names

getTableFunctionNamesAsync
Returns
Promise.Array: An array of table function names (strings)

getRuntimeTableFunctionNamesAsync

Returns a list of available runtime table function names

getRuntimeTableFunctionNamesAsync
Returns
Promise.Array: An array of runtime table function names (strings)

getTableFunctionDetailsAsync

getTableFunctionDetailsAsync
Parameters
udtfNames (Array.String) The table function names to retrieve details for
Returns
Promise.Array: An array of TUserDefinedTableFunction objects describing each supplied table function

getCompletionHintsAsync

Submits an SQL string to the backend and returns a completion hints object.

getCompletionHintsAsync
Parameters
queryString (String) A fragment of SQL input.
options (Object) An options object continaing the current cursor position, 1-indexed from the start of queryString .
Returns
Promise.Array: An array of completion hints objects that contains the completion hints.
Example
const queryString = "f";
const cursor = 1;

con.getCompletionHints(queryString, cursor, function(error, result) {
       console.log(result)
     });

 [{
   hints: ["FROM"],
   replaced: "f",
   type: 7
  }]

getCompletionHints

Submits an SQL string to the backend and returns a completion hints object.

getCompletionHints
Parameters
queryString (String) A fragment of SQL input.
options (Object) An options object continaing the current cursor position, 1-indexed from the start of queryString .
callback (Function) An optional callback function with the signature (err, result) => result .
Returns
Promise.Array: An array of completion hints objects that contains the completion hints.
Example
const queryString = "f";
const cursor = 1;

con.getCompletionHints(queryString, cursor, function(error, result) {
       console.log(result)
     });

 [{
   hints: ["FROM"],
   replaced: "f",
   type: 7
  }]

invertDatumTypes

Create an array-like object from TDatumType by changing the order of the string key and numerical value.

invertDatumTypes(): Undefined
Returns
Undefined: This function does not return anything.

getFieldsAsync

Get a list of field objects for a specified table.

getFieldsAsync
Parameters
tableName (String) Name of table containing field names.
Returns
Promise.Array<Object>: The formatted list of field objects.
Example

Get the list of fields from a specific table:

con.getFields('flights', (err, res) => console.log(res))
// [{
  name: 'fieldName',
  type: 'BIGINT',
  is_array: false,
  is_dict: false
}, ...]

getFields

Get a list of field objects for a specified table.

getFields
Parameters
tableName (String) Name of table containing field names.
callback (Function) An optional callback that takes ( err, results ).
Returns
Promise.Array<Object>: The formatted list of field objects.
Example

Get the list of fields from a specific table:

con.getFields('flights', (err, res) => console.log(res))
// [{
  name: 'fieldName',
  type: 'BIGINT',
  is_array: false,
  is_dict: false
}, ...]

createTableAsync

Create a table and persist it to the backend.

createTableAsync
Parameters
tableName (String) The name of the new table.
rowDescObj (Array<TColumnType>) Fields in the new table.
createParams (TCreateParams) Properties to apply to the new table (e.g. replicated)
options (Object)
Name Description
options.useUnmodifiedRowDesc boolean By default, createTableAsync calls createTable using properties from both rowDescObj and the descriptor last returned by detectColumnTypesAsync. If true, this simply calls createTable with the passed rowDescObj, removing the dependence on the previous detectColumnTypesAsync call
Returns
Promise<undefined>: Generates an error if unsuccessful, or returns undefined if successful.
Example

Create a new table:

con.createTable('mynewtable', [TColumnType, TColumnType, ...], 0).then(res => console.log(res));
 // undefined

importTableAsync

Import a delimited table from a file.

importTableAsync
Parameters
tableName (String) The name of the new table.
fileName (String) The name of the file containing the table.
copyParams (TCopyParams) See TCopyParams
headers (Array<TColumnType>) A collection of metadata related to the table headers.

importTableGeoAsync

Import a geo table from a file.

importTableGeoAsync
Parameters
tableName (String) The name of the new geo table.
fileName (String) The name of the file containing the table.
copyParams (TCopyParams) See TCopyParams
headers (Array<TColumnType>) A colleciton of metadata related to the table headers.

renderVegaAsync

Use for backend rendering. This method fetches a PNG image that is a render of the Vega JSON object. The Image will be a string if using browser-connector.js, or a Buffer otherwise.

renderVegaAsync
Parameters
widgetid (Number) The widget ID of the calling widget.
vega (String) The Vega JSON.
options (Object) The options for the render query.
Name Description
options.compressionLevel Number The PNG compression level. Range: 1 (low compression, faster) to 10 (high compression, slower). Default: 3.
Returns
Promise.Image: Base64 image.

renderVega

Use for backend rendering. This method fetches a PNG image that is a render of the Vega JSON object. The Image will be a string if using browser-connector.js, or a Buffer otherwise.

renderVega
Parameters
widgetid (Number) The widget ID of the calling widget.
vega (String) The Vega JSON.
options (Object) The options for the render query.
Name Description
options.compressionLevel Number The PNG compression level. Range: 1 (low compression, faster) to 10 (high compression, slower). Default: 3.
callback (Function) An optional callback that takes (err, success) as its signature.
Returns
Promise.Image: Base64 image.

getResultRowForPixelAsync

Used primarily for backend-rendered maps; fetches the row for a specific table that was last rendered at a pixel.

getResultRowForPixelAsync
Parameters
widgetId (Number) The widget ID of the caller.
pixel (TPixel) The pixel. The lower-left corner is pixel (0,0).
tableColNamesMap (Object) Map of the object of tableName to the array of column names.
pixelRadius (Number = 2) The radius around the primary pixel to search within.
Returns
String: Current result nonce

getResultRowForPixel

Used primarily for backend-rendered maps; fetches the row for a specific table that was last rendered at a pixel.

getResultRowForPixel
Parameters
widgetId (Number) The widget ID of the caller.
pixel (TPixel) The pixel. The lower-left corner is pixel (0,0).
tableColNamesMap (Object) Map of the object of tableName to the array of column names.
pixelRadius (Number = 2) The radius around the primary pixel to search within.
callback (Function) An optional callback function with the signature (err, result) => result .
Returns
String: Current result nonce

sessionId

Get or set the session ID used by the server to serve the correct data. This is typically set by connect and should not be set manually.

sessionId(sessionId: Number): (Number | DbCon)
Parameters
sessionId (Number) The session ID of the current connection.
Returns
(Number | DbCon): The session ID or MapD connector itself.
Example

Get the session ID:

con.sessionId();
// sessionID === 3145846410

Set the session ID:

var con = new DbCon().connect().sessionId(3415846410);
// NOTE: It is generally unsafe to set the session ID manually.

host

Get or set the connection server hostname. This is is typically the first method called after instantiating a new DbCon.

host(host: String): (String | DbCon)
Parameters
host (String) The hostname address.
Returns
(String | DbCon): The hostname or MapD connector itself.
Example

Set the hostname:

var con = new DbCon().host('localhost');

Get the hostname:

var host = con.host();
// host === 'localhost'

port

Get or set the connection port.

port(port: String): (String | DbCon)
Parameters
port (String) The port to connect on.
Returns
(String | DbCon): The port or MapD connector itself.
Example

Set the port:

var con = new DbCon().port('8080');

Get the port:

var port = con.port();
// port === '8080'

user

Get or set the username with which to authenticate.

user(user: String): (String | DbCon)
Parameters
user (String) The username with which to authenticate.
Returns
(String | DbCon): The username or MapD connector itself.
Example

Set the username:

var con = new DbCon().user('foo');

Get the username:

var username = con.user();
// user === 'foo'

password

Get or set the user password for authentication.

password(password: String): (String | DbCon)
Parameters
password (String) The password with which to authenticate.
Returns
(String | DbCon): The password or MapD connector itself.
Example

Set the password:

var con = new DbCon().password('bar');

Get the username:

var password = con.password();
// password === 'bar'

dbName

Get or set the name of the database to connect to.

dbName(dbName: String): (String | DbCon)
Parameters
dbName (String) The database to connect to.
Returns
(String | DbCon): The name of the database or the MapD connector itself.
Example

Set the database name:

var con = new DbCon().dbName('myDatabase');

Get the database name:

var dbName = con.dbName();
// dbName === 'myDatabase'

logging

Configure whether raw query strings are logged to the console. Used primarily for debugging; false by default.

logging(logging: Boolean): (Boolean | DbCon)
Parameters
logging (Boolean) Set to true to enable logging.
Returns
(Boolean | DbCon): The current logging flag or MapD connector itself.
Example

Set logging to true:

var con = new DbCon().logging(true);

Get the logging flag:

var isLogging = con.logging();
// isLogging === true

platform

The name of the platform.

platform(platform: String): (String | DbCon)
Parameters
platform (String) The platform; "heavydb" by default.
Returns
(String | DbCon): The platform or MapD connector itself.
Example

Set the platform name:

var con = new DbCon().platform('myPlatform');

Get the platform name:

var platform = con.platform();
// platform === 'myPlatform'

numConnections

Get the number of connections that are currently open.

numConnections(): Number
Returns
Number: The number of open connections.
Example

Get the number of connections:

var numConnections = con.numConnections();
// numConnections === 1

protocol

The protocol to use for requests.

protocol(protocol: String): (String | DbCon)
Parameters
protocol (String) http or https .
Returns
(String | DbCon): The protocol or DbCon itself.
Example

Set the protocol:

var con = new DbCon().protocol('http');

Get the protocol:

var protocol = con.protocol();
// protocol === 'http'

disableAutoReconnect

Disables logic that automatically tries to reconnect to the server if there's an error

disableAutoReconnect(disable: Boolean?): (Boolean | DbCon)
Parameters
disable (Boolean?) If true, disables auto-reconnect
Returns
(Boolean | DbCon): The status of auto-reconnect, or DbCon itself.

getEndpoints

Generates a list of endpoints from the connection parameters.

getEndpoints(): Array<String>
Returns
Array<String>: List of endpoints.
Example

Get the endpoints:

var con = new DbCon().protocol('http').host('localhost').port('8000');
var endpoints = con.getEndpoints();
// endpoints === [ 'http://localhost:8000' ]

setLicenseKey

Set the license for Trial or Enterprise

setLicenseKey(key: String, config: Object): Promise<Object>
Parameters
key (String) The key to install
config (Object) Protocol, host and port to connect to
Name Description
config.protocol any
config.host any
config.port any
Returns
Promise<Object>: Claims or Error.

getLicenseClaims

Get the license for Trial or Enterprise

getLicenseClaims(config: Object): Promise<Object>
Parameters
config (Object) Protocol, host and port to connect to
Name Description
config.protocol any
config.host any
config.port any
Returns
Promise<Object>: Claims or Error.

timestampToMs

Converts a raw integer timestamp value from the DB into milliseconds. The DB timestamp value may represent seconds, ms, us, or ns depending on the precision of the column. This value is truncated or extended as necessary to convert to ms precision. The returned ms value is suitable for passing to the JS Date object constructor.

timestampToMs(timestamp: Number, precision: Number): Number
Parameters
timestamp (Number) The raw integer timestamp in the database.
precision (Number) The precision of the timestamp column in the database.
Returns
Number: The equivalent timestamp in milliseconds.

valueToBoolean

Converts a Number/BigInt value to a Boolean

valueToBoolean(value: BigInt): Boolean
Parameters
value (BigInt) A BigInt value
Returns
Boolean: The equivalent boolean value representing the buffer

processColumnarResults

Process the column-based results from the query in a row-based format. (Returning row-based results directly from the server is inefficient.)

processColumnarResults(data: TRowSet, eliminateNullRows: Boolean, dataEnum: Object): Object
Parameters
data (TRowSet) The column-based data returned from a query.
eliminateNullRows (Boolean) A flag that removes null rows from results.
dataEnum (Object) A list of types created from when executing #invertDatumTypes .
Returns
Object: The formatted results of the query.

processQueryResults

Determines how to process raw results when they return from the server.

processQueryResults(logging: Boolean, updateQueryTimes: Function, options: Object, result: Object): Object
Parameters
logging (Boolean) If enabled, shows on the console how long the query took to run.
updateQueryTimes (Function) A function that updates internal query times on the connector.
options (Object) A list of options for processing the results.
Name Description
options.isImage Boolean Set to true when querying for backend-rendered images.
options.eliminateNullRows Boolean Removes null rows.
options.query String The SQL query string used only for logging.
options.queryId Number The ID of the query.
options.conId Number The unique connector identification.
options.estimatedQueryTime String The estimate of the query time.
result (Object) The query result used to decide whether to process as column or row results.
Returns
Object: result if image, otherwise formatted results.

processRowResults

Query for row-based results from the server. In general, is inefficient and should be avoided. Instead, use processColumnarResults and then convert the results to row-based format.

processRowResults(data: TRowSet, eliminateNullRows: Boolean, datumEnum: Object): Object
Parameters
data (TRowSet) The row-based data returned from a query.
eliminateNullRows (Boolean) Flag that removes null rows from results.
datumEnum (Object) A list of types created from when executing #invertDatumTypes .
Returns
Object: The formatted results of the query.
Example
<caption> Return row-based results directly from the server:

TTypeInfo

The information about a particular field in a given table.

TTypeInfo

Type: TTypeInfo

Properties
encoding (Number)
is_array (Boolean)
nullable (Boolean)
type (Number)

completion_hints

The types of the completion hint response object.

completion_hints

Type: completion_hints

Properties
session (TSessionId)
sql (String)
cursor (Number)

TTableType

The types of tables that uploaded through the importer TTableType.

TTableType

Type: TTableType

Properties
DELIMITED (Number) : =0
POLYGON (Number) : =1

TDetectResult

Contains the result from calling detectColumnTypes.

TDetectResult

Type: TDetectResult

Properties
copy_params (TCopyParams)
row_set (TRowSet)

TFrontendView

The data stored for a dashboard.

TFrontendView

Type: TFrontendView

Properties
image_hash (String) : The lookup hash for the dashboard thumbnail image.
update_time (String) : The timestamp from the last saved update.
view_name (String) : The name of the dashboard or the shortened share link hash.
view_state (String) : The Base64-encoded string containing the details about the current state of the dashboard.

TDatumType

The valid types for database field values.

TDatumType

Type: Object

Properties
SMALLINT (Number) : =0
INT (Number) : =1
BIGINT (Number) : =2
FLOAT (Number) : =3
DECIMAL (Number) : =4
DOUBLE (Number) : =5
STR (Number) : =6
TIME (Number) : =7
TIMESTAMP (Number) : =8
DATE (Number) : =9
BOOL (Number) : =10
INTERVAL_DAY_TIME (Number) : =11
INTERVAL_YEAR_MONTH (Number) : =12
POINT (Number) : =13
LINESTRING (Number) : =14
MULTILINESTRING (Number) : =20
POLYGON (Number) : =15
MULTIPOLYGON (Number) : =16
TINYINT (Number) : =17
GEOMETRY (Number) : =18
GEOGRAPHY (Number) : =19

TImportStatus

Import completion status of a table.

TImportStatus

Type: TImportStatus

Properties
elapsed (Number)
rows_completed (Number)
rows_estimated (Number)

TDatumVal

The value of an individual cell in a table.

TDatumVal

Type: TDatumVal

Properties
arr_val (Array)
int_val (Number)
real_val (Number)
str_val (String)

TDatum

The value and state of an individual data cell in a table.

TDatum

Type: TDatum

Properties
is_null (Boolean)
val (TDatumVal)

TRow

A row of data in a table.

TRow

Type: TRow

Properties
cols (Array<TDatum>) : The array of individual data cells in a table.

TColumnType

TColumnType

Type: TColumnType

Properties
col_name (String) : The name of the table field.
col_type (TTypeInfo) : The information about the field.

TRowSet

Contains parsed table data.

TRowSet

Type: TRowSet

Properties
columns (Array)
is_columnar (Boolean)
row_desc (Array<TColumnType>) : A list of field names and their associated information.
rows (Array<TRow>)

TServerStatus

The permissions granted by the server.

TServerStatus

Type: TServerStatus

Properties
read_only (Boolean) : Indicates whether the server accepts write operations, such as saving.
rendering_enabled (Boolean) : Indicates whether backend rendering is enabled on the server.
version (String) : The current version of the server.

TCopyParams

The configuration required to import a table into MapD. See detectColumnTypes for a usage example.

TCopyParams

Type: TCopyParams

Properties
array_begin (String) : =null
array_delim (String) : =null
array_end (String) : =null
delimiter (String) : ="" - The delimiter character; for example, comma, [TAB] , or pipe.
escape (String) : =null
has_header (Boolean) : =null
line_delim (String) : =null
null_str (String) : ="" - The token used by the table to express a null value; for example, some systems use 'nil' or 'none'.
quote (String) : =null
quoted (Boolean) : =true - Indicates whether the string fields should be wrapped in quotes.
threads (Number) : =null