How to use the arangojs.Database function in arangojs

To help you get started, we’ve selected a few arangojs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github harpagon210 / steemsmartcontracts / test / tokens.js View on Github external
plugin.cp.stdout.on('data', data => console.log(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));
  plugin.cp.stderr.on('data', data => console.error(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));

  plugins[newPlugin.PLUGIN_NAME] = plugin;

  return send(newPlugin.PLUGIN_NAME, 'MASTER', { action: 'init', payload: conf });
};

const unloadPlugin = (plugin) => {
  plugins[plugin.PLUGIN_NAME].cp.kill('SIGINT');
  plugins[plugin.PLUGIN_NAME] = null;
  jobs = new Map();
  currentJobId = 0;
}

const db = new Database(conf.databaseURL);

const FORK_BLOCK_NUMBER = 30896500;
const SSC_STORE_QTY = '0.001';

// tokens
describe('Tokens smart contract', function () {
  this.timeout(10000);

  beforeEach((done) => {
    new Promise(async (resolve) => {
      try {
        await db.dropDatabase(conf.databaseName);
      } catch (error) {

      }
github harpagon210 / steemsmartcontracts / test / smarttokens.js View on Github external
plugin.cp.stdout.on('data', data => console.log(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));
  plugin.cp.stderr.on('data', data => console.error(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));

  plugins[newPlugin.PLUGIN_NAME] = plugin;

  return send(newPlugin.PLUGIN_NAME, 'MASTER', { action: 'init', payload: conf });
};

const unloadPlugin = (plugin) => {
  plugins[plugin.PLUGIN_NAME].cp.kill('SIGINT');
  plugins[plugin.PLUGIN_NAME] = null;
  jobs = new Map();
  currentJobId = 0;
}

const db = new Database(conf.databaseURL);

const FORK_BLOCK_NUMBER = 30896500;

// smart tokens
describe('smart tokens', function () {
  this.timeout(30000);

  beforeEach((done) => {
    new Promise(async (resolve) => {
      try {
        await db.dropDatabase(conf.databaseName);
      } catch (error) {

      }

      resolve();
github OriginTrail / ot-node / test / bdd / steps / hooks.js View on Github external
AfterAll(async function () {
    // Delete almost all Arango dbs.
    const systemDb = new Database();
    systemDb.useBasicAuth(config.database.username, config.database.password);

    const listOfDatabases = await systemDb.listDatabases();

    const that = this;
    listOfDatabases.forEach(async function (databaseItem) {
        if (databaseItem !== '_system' && databaseItem !== 'origintrail' && databaseItem !== 'origintrail-develop' && databaseItem !== 'origintrail-staging' && databaseItem !== 'origintrail-stable') {
            try {
                await systemDb.dropDatabase(databaseItem);
            } catch (error) {
                that.logger.log(`Oops, failed to delete database: ${databaseItem}`);
                that.logger.log(error);
            }
        }
    });
github OriginTrail / ot-node / scripts / setup.js View on Github external
async function resetArangoDb(database) {
    console.info(`Setting up graph database '${database.database}'...`);
    const systemDb = new Database();
    systemDb.useBasicAuth(database.username, database.password);

    // Drop test database if exist.
    const listOfDatabases = await systemDb.listDatabases();
    if (listOfDatabases.includes(database.database)) {
        await
        systemDb.dropDatabase(database.database);
    }

    await
    systemDb.createDatabase(
        database.database,
        [{ username: database.username, passwd: database.password, active: true }],
    );
}
github AEB-labs / cruddl / spec / regression / initialization.ts View on Github external
export function getTempDatabase(): Database {
    const db = new Database({
        url: DATABASE_URL
    });
    db.useDatabase(DATABASE_NAME);
    return db;
}
github OriginTrail / ot-node / modules / Database / Arangojs.js View on Github external
constructor(username, password, database, host, port, log) {
        this.log = log;
        this.db = new Database(`http://${host}:${port}`);
        this.db.useDatabase(database);
        this.db.useBasicAuth(username, password);
    }
github OriginTrail / ot-node / modules / Utilities.js View on Github external
return new Promise((resolve, reject) => {
            switch (config.database.provider) {
            case 'arangodb': {
                const systemDb = new Database();
                systemDb.useBasicAuth(config.database.username, config.database.password);
                systemDb.listDatabases().then((result) => {
                    let databaseAlreadyExists = false;
                    for (let i = 0; i < result.length; i += 1) {
                        if (result[i].toString() === config.database.database) {
                            databaseAlreadyExists = true;
                        }
                    }
                    if (!databaseAlreadyExists) {
                        systemDb.createDatabase(
                            config.database.database,
                            [{
                                username: config.database.username,
                                passwd: config.database.password,
                                active: true,
                            }],
github aguskov1987 / arango-graphit / src / app / providers / arango.service.ts View on Github external
constructor(h: Http) {
    this.connector = new arango.Database({ url: StoreUtils.host });
    this.connector.useBasicAuth(StoreUtils.username, StoreUtils.password);
    this.http = h;
    this.headers = new Headers();
    this.headers.append("Authorization", "Basic " + btoa(StoreUtils.username + ":" + StoreUtils.password));
  }
github awesome-graphql-space / lina / src / lina-arango / arangodb.providers.ts View on Github external
useFactory: async (): Promise => {
      const db = new Database();
      db.useDatabase('');
      db.useBasicAuth('');

      return db;
    },
  },