Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "arangojs in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'arangojs' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

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) {

      }
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();
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);
            }
        }
    });
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 }],
    );
}
async exists(collection = required(), key = required(), value = required()) {
    const aql = arangojs.aql;
    const collectionObject = await this._collection(collection)

    let exists = false;
    try {
      const cursor = await this.db.query(aql`
        FOR o IN ${collectionObject}
        FILTER o.${key} == ${value}
        RETURN o
      `, { count: true })

      // if we have more or equal to 1, it exists already.
      if(cursor.count >= 1) exists = true
    } catch(e) {
      debug("exists", "error", e.message)
      exists = true
    }
import { Database } from 'arangojs';
import { graphql, GraphQLSchema } from 'graphql';
import * as path from 'path';
import { SchemaContext } from '../../../src/config/global';
import { ArangoDBAdapter } from '../../../src/database/arangodb';
import { Project } from '../../../src/project/project';
import { loadProjectFromDir } from '../../../src/project/project-from-fs';
import { range } from '../../../src/utils/utils';
import { Log4jsLoggerProvider } from '../../helpers/log4js-logger-provider';
import { createTempDatabase } from '../../regression/initialization';

// arangojs typings for this are completely broken
export const aql: (template: TemplateStringsArray, ...args: any[]) => any = require('arangojs').aql;

const MODEL_PATH = path.resolve(__dirname, '../../regression/papers/model');

export interface TestEnvironment {
    getDB(): Database;

    exec(graphql: string, variables?: { [name: string]: any }): any
}

const schemaContext: SchemaContext = { loggerProvider: new Log4jsLoggerProvider('warn'), getExecutionOptions: ({ context }) => ({ authRoles: context.authRoles }) };

export async function createTestProject(modelPath: string = MODEL_PATH): Promise<{ project: Project, schema: GraphQLSchema }> {
    const project = await loadProjectFromDir(modelPath, schemaContext);
    const dbConfig = await createTempDatabase();
    const dbAdapter = new ArangoDBAdapter(dbConfig, schemaContext);
    const schema = project.createSchema(dbAdapter);
function hemeraArangoStore(hemera, opts, done) {
  const connections = {}
  const topic = 'arango-store'
  const Joi = hemera.joi

  hemera.decorate('arango', Arangojs)
  hemera.decorate('aqlTemplate', Arangojs.aql)

  function useDb(databaseName) {
    if (connections[databaseName]) {
      return connections[databaseName]
    }

    // try to create new db connection based on arango settings
    if (opts.arango.databaseName) {
      let options = Object.assign({}, opts.arango)

      if (databaseName) {
        options.databaseName = databaseName
      }

      connections[databaseName] = new Arangojs.Database(options)
static async _getDatabase () {
    if (Model._database) {
      return Model._database
    }

    const dbName = this.options.database
    const host = this.options.host || 'localhost'
    const port = this.options.port || 8529
    const username = this.options.username || 'root'
    const password = this.options.password || ''
    const url = this.options.url || `http://${username}:${password}@${host}:${port}`

    const db = arangojs({
      url
    })

    try {
      await db.createDatabase(dbName)
    } catch (e) {
      // throw new Error(get(e, 'response.body.errorMessage', e))
    }

    db.useDatabase(dbName)

    Model._database = db
    return db
  }
{ method, url, headers, body, requestInstrumentation }: RequestOptions,
            callback: Errback
        ) {
            // this is the last change we cancel a request
            // we don't cancel running requests because arangodb does not kill queries when the request ist terminated
            // thus, we keep the request open
            // - to get notified if the request completes pretty quickly anyway so we don't need to kill the query
            // - to take up a socket so that no new query is sent on it while the query is not yet killed
            if (requestInstrumentation && requestInstrumentation.isCancelled) {
                return callback(new Error(`Request has been cancelled by caller before it was sent`));
            }

            notifyAboutPhaseEnd(requestInstrumentation, 'queuing');
            let path = baseUrlParts.pathname
                ? url.pathname
                    ? joinPath(baseUrlParts.pathname, url.pathname)
                    : baseUrlParts.pathname
                : url.pathname;
            const search = url.search
                ? baseUrlParts.search
                    ? `${baseUrlParts.search}&${url.search.slice(1)}`
                    : url.search
                : baseUrlParts.search;
            if (search) {
                path += search;
            }
            if (body && !headers['content-length']) {
                headers['content-length'] = String(Buffer.byteLength(body));
            }
            if (!headers['authorization']) {
                headers['authorization'] = `Basic ${btoa(
                    baseUrlParts.auth || 'root:'
const arango = require('arangojs');
const aql = arango.aql;
const db = arango({
  url: 'http://root:@127.0.0.1:8529',
  databaseName: 'rescue',    //数据库名称
  arangoVersion: 20800
});

//05-18
/*
console.log('generating...');
console.log('creating collections...');

Promise.all([
  db.collection('invites').create(),
  db.collection('personalForums').create(),
  db.collection('usersSubscribe').create(),
  db.collection('usersBehavior').create()

Is your System Free of Underlying Vulnerabilities?
Find Out Now