lib/traildb.js
function (options) {
  this._db = lib.tdb_init();

  const r = lib.tdb_open(this._db, ref.allocCString(options.path));
  if (r !== 0) {
    throw new TrailDBError('Could not open TrailDB: ' + r);
  }

  this.numTrails = lib.tdb_num_trails(this._db);
  this.numEvents = lib.tdb_num_events(this._db);
  this.numFields = lib.tdb_num_fields(this._db);

  this.fieldNames = [];
  this.fieldNameToId = {};
  for (let i = 0; i < this.numFields; i++) {
    this.fieldNames[i] = lib.tdb_get_field_name(this._db, i);
    this.fieldNameToId[this.fieldNames[i]] = i;
  }

  return this;
}
function (options) {
  this._db = lib.tdb_init();

  const r = lib.tdb_open(this._db, ref.allocCString(options.path));
  if (r !== 0) {
    throw new TrailDBError('Could not open TrailDB: ' + r);
  }

  this.numTrails = lib.tdb_num_trails(this._db);
  this.numEvents = lib.tdb_num_events(this._db);
  this.numFields = lib.tdb_num_fields(this._db);

  this.fieldNames = [];
  this.fieldNameToId = {};
  for (let i = 0; i < this.numFields; i++) {
    this.fieldNames[i] = lib.tdb_get_field_name(this._db, i);
    this.fieldNameToId[this.fieldNames[i]] = i;
  }

  return this;
}
function ( options ) { this . _db = lib . tdb_init ( ) ; const r = lib . tdb_open ( this . _db , ref . allocCString ( options . path ) ) ; if ( r !== 0 ) { throw new TrailDBError ( 'Could not open TrailDB: ' + r ) ; } this . numTrails = lib . tdb_num_trails ( this . _db ) ; this . numEvents = lib . tdb_num_events ( this . _db ) ; this . numFields = lib . tdb_num_fields ( this . _db ) ; this . fieldNames = [ ] ; this . fieldNameToId = { } ; for ( let i = 0 ; i < this . numFields ; i ++ ) { this . fieldNames [ i ] = lib . tdb_get_field_name ( this . _db , i ) ; this . fieldNameToId [ this . fieldNames [ i ] ] = i ; } return this ; }
TrailDB class Query a TrailDB.  
Opens a TrailDB at path.
@param {String} options.path - TrailDB output path (without .tdb).
@return {Object} tdb - TrailDB object.
TrailDB class Query a TrailDB . Opens a TrailDB at path .