How to use the lokijs/src/loki-fs-structured-adapter.js function in lokijs

To help you get started, we’ve selected a few lokijs 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 repetere / lowkie / lib / connect.js View on Github external
function connect(dbpath = defaultDBPath, options = {}, lowkieConfig = {}, dbconnectionname = 'default') {
  this.config = Object.assign(this.config, lowkieConfig);
  const dbname = path.resolve(dbpath);
  const adapter = (this.config.adapterType === 'file') ? { adapter: new lokiFSAdapter(dbname), } : {};
  const lokiDBOptions = Object.assign({
      autosave: true,
      autosaveInterval: 5000, // 5 seconds
    },
    adapter, options);
  const t = setImmediate(() => {
    this.connection.emit('connecting', { dbname, options, });
    clearImmediate(t);
  });
  const db = new loki(dbname, lokiDBOptions);
  const ensureAdapterFilePromise = () => {
    if (!this.config.adapterType) {
      return Promise.reject(new Error('Invalid Adapter Type'));
    } else {
      return (this.config.adapterType === 'file') ?
        new Promise((resolve, reject) => {
github cyclux / tanglemonitor / backend / modules / DB.js View on Github external
const initLokiJS = (options, callback) => {
  const adapter = new lfsa();

  const persistence = config.DB.storageDuration > 0 ? true : false;
  lokiDB = new loki('DB/lokiDB', {
    adapter: adapter,
    autoload: persistence,
    autoloadCallback: lokiDBInitialize,
    autosave: persistence,
    autosaveInterval: 1 * 60 * 1000
  });

  // autoloadCallback does not call lokiDBInitialize if persistence if false, so here we call it anyway
  if (!persistence) {
    lokiDBInitialize();
  }

  callback(Time.Stamp() + 'Standalone DB [LokiJS] initialized...');
github ethereum-alarm-clock / cli / src / TimeNode / index.js View on Github external
}

  // Process the keystores.
  let encKeystores = [];
  // eslint-disable-next-line
  program.wallet.map((file) => {
    const keystore = fs.readFileSync(file, 'utf8');
    if (typeof JSON.parse(keystore).length !== 'undefined') {
      encKeystores = encKeystores.concat(JSON.parse(keystore));
    } else {
      encKeystores.push(keystore);
    }
  });

  const statsDb = new Loki('stats.json', {
    adapter: new Lfsa(),
    autosave: true,
    autosaveInterval: 5000,
  });

  // Economic Strategy
  const economicStrategy = {
    maxDeposit: options.maxDeposit
      ? new BigNumber(options.maxDeposit).times(wei)
      : Config.DEFAULT_ECONOMIC_STRATEGY.maxDeposit,
    minBalance: options.minBalance
      ? new BigNumber(options.minBalance).times(wei)
      : Config.DEFAULT_ECONOMIC_STRATEGY.minBalance,
    minProfitability: options.minProfitability
      ? new BigNumber(options.minProfitability).times(wei)
      : Config.DEFAULT_ECONOMIC_STRATEGY.minProfitability,
    maxGasSubsidy: options.maxGasSubsidy