@param {Function} app
@param {setupDb} app.setupDb

@returns {undefined}
439638
function setupDb( app ) {
  app.setupDb = setupMongoose(
    {
      connection: {
        debug: config.debug,
        uri: {
          database: config.database,
          password: config.password,
          username: config.username
        }
      },
      schemas: [
        {
          'User': User
        }
      ]
    }
  )

  app.setupDb()
    .then(
      function ( db ) {
        app.db = db
      }
    )
    .catch(
      function ( err ) {
        app.db = {
          error: err
        }
      }
    )
}
601438
def install_app(cls, id, raw, api=None, raw_format=None):
        
        api = api if api else cls._API
        raw_format = raw_format.lower() if raw_format else AppRawFormat.JSON
        extra = {
            'resource': cls.__name__,
            'query': {
                'id': id,
                'data': raw
            }
        }
        logger.info('Installing app', extra=extra)

        # Set content type for raw app data
        if raw_format not in cls._CONTENT_TYPE.keys():
            raise SbgError(
                'Unsupported raw data format: "{}".'
                .format(raw_format))
        headers = {'Content-Type': cls._CONTENT_TYPE[raw_format]}

        app = api.post(
            url=cls._URL['raw'].format(id=id),
            data=raw,
            headers=headers,
        ).json()
        app_wrapper = api.get(
            url=cls._URL['get'].format(id=app['sbg:id'])).json()
        return App(api=api, **app_wrapper)
1173815
function(apps) {

  var filepath = getGlobalConfig().appRegistry;

  var tempFilepath = filepath + '.tmp';

  // Write to temp file.
  return Promise.fromNode(function(cb) {
    fs.writeFile(tempFilepath, JSON.stringify(apps), cb);
    log.debug(format('Setting app registry with %j', apps));
  })
  // Rename temp file to normal file.
  .then(function() {
    return Promise.fromNode(function(cb) {
      fs.rename(tempFilepath, filepath, cb);
    });
  });

}
756937
def setup(app) -> Dict[str, Any]:
    
    app.connect("doctree-read", on_doctree_read)
    app.connect("builder-inited", on_builder_inited)
    app.add_css_file("uqbar.css")
    app.add_node(
        nodes.classifier, override=True, html=(visit_classifier, depart_classifier)
    )
    app.add_node(
        nodes.definition, override=True, html=(visit_definition, depart_definition)
    )
    app.add_node(nodes.term, override=True, html=(visit_term, depart_term))
    return {
        "version": uqbar.__version__,
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }
198557
function loadDatabase(config = {}) {
    if (typeof config.ignore === 'string' || Array.isArray(config.ignore)) {
      app.deprecate(`[egg-sequelize] if you want to exclude ${config.ignore} when load models, please set to config.sequelize.exclude instead of config.sequelize.ignore`);
      config.exclude = config.ignore;
      delete config.ignore;
    }

    const sequelize = new app.Sequelize(config.database, config.username, config.password, config);

    const delegate = config.delegate.split('.');
    const len = delegate.length;

    let model = app;
    let context = app.context;
    for (let i = 0; i < len - 1; i++) {
      model = model[delegate[i]] = model[delegate[i]] || {};
      context = context[delegate[i]] = context[delegate[i]] || {};
    }

    if (model[delegate[len - 1]]) {
      throw new Error(`[egg-sequelize] app[${config.delegate}] is already defined`);
    }

    Object.defineProperty(model, delegate[len - 1], {
      value: sequelize,
      writable: false,
      configurable: true,
    });

    const DELEGATE = Symbol(`context#sequelize_${config.delegate}`);
    Object.defineProperty(context, delegate[len - 1], {
      get() {
        // context.model is different with app.model
        // so we can change the properties of ctx.model.xxx
        if (!this[DELEGATE]) this[DELEGATE] = Object.create(model[delegate[len - 1]]);
        return this[DELEGATE];
      },
      configurable: true,
    });

    const modelDir = path.join(app.baseDir, 'app', config.baseDir);

    const models = [];
    const target = Symbol(config.delegate);

    app.loader.loadToApp(modelDir, target, {
      caseStyle: 'upper',
      ignore: config.exclude,
      filter(model) {
        if (!model || !model.sequelize) return false;
        models.push(model);
        return true;
      },
      initializer(factory) {
        if (typeof factory === 'function') {
          return factory(app, sequelize);
        }
      },
    });
    Object.assign(model[delegate[len - 1]], app[target]);

    models.forEach(model => {
      typeof model.associate === 'function' && model.associate();
    });

    return model[delegate[len - 1]];
  }
602553
function _db(dbConfig, dataPath) {
  if (dbConfig.dialect === 'sqlite') {
    /* eslint-disable-next-line no-param-reassign */
    dbConfig.storage = resolve(dataPath, 'vapid.sqlite');
  }

  return new Database(dbConfig);
}
429089
function runTool(platform, args, done) {
  if (args.length < 1) {
    console.log('usage: query.js file.wtf-trace "[query string]"');
    done(1);
    return;
  }

  var inputFile = args[0];
  var exprArgs = args.slice(1);
  var expr = exprArgs.join(' ').trim();

  console.log('Querying ' + inputFile + '...');

  // Create database for querying.
  var loadStart = wtf.now();
  wtf.db.load(inputFile, function(db) {
    if (db instanceof Error) {
      console.log('ERROR: unable to open ' + inputFile, db);
      done(1);
      return;
    }

    var loadDuration = wtf.now() - loadStart;
    console.log('Database loaded in ' + loadDuration.toFixed(3) + 'ms');
    console.log('');

    queryDatabase(db, expr);

    done(0);
  });
}
1167527
function(db, opt_err) {

    if (df.hasFired()) {
      goog.log.warning(me.logger, 'database already set.');
    } else if (goog.isDef(opt_err)) {
      goog.log.warning(me.logger, opt_err ? opt_err.message : 'Error received.');
      me.idx_db_ = null;
      df.errback(opt_err);
    } else {
      goog.asserts.assertObject(db, 'db');
      me.idx_db_ = db;
      me.idx_db_.onabort = function(e) {
        goog.log.finest(me.logger, me + ': abort');
        var request = /** @type {IDBRequest} */ (e.target);
        me.onError(request.error);
      };
      me.idx_db_.onerror = function(e) {
        if (ydn.db.con.IndexedDb.DEBUG) {
          goog.global.console.log(e);
        }
        goog.log.finest(me.logger, me + ': error');
        var request = /** @type {IDBRequest} */ (e.target);
        me.onError(request.error);
      };

      /**
       * @this {null}
       * @param {IDBVersionChangeEvent} event event.
       */
      me.idx_db_.onversionchange = function(event) {
        // Handle version changes while a web app is open in another tab
        // https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB#
        // Version_changes_while_a_web_app_is_open_in_another_tab
        //
        if (ydn.db.con.IndexedDb.DEBUG) {
          goog.global.console.log([this, event]);
        }
        goog.log.finest(me.logger, me + ' closing connection for onversionchange to: ' +
            event.version);
        if (me.idx_db_) {
          me.idx_db_.onabort = null;
          me.idx_db_.onblocked = null;
          me.idx_db_.onerror = null;
          me.idx_db_.onversionchange = null;
          me.onVersionChange(event);
          if (!event.defaultPrevented) {
            me.idx_db_.close();
            me.idx_db_ = null;
            var e = new Error();
            e.name = event.type;
            me.onFail(e);
          }
        }
      };
      df.callback(parseFloat(old_version));
    }

  }
1293658
function App() {
  return (
    <Store
      actions={{
        loadQuote,
        prevQuote,
        nextQuote,
        toggleColor
      }}
      initializers={{
        quotes: "loadQuote",
        numQuotes: "loadQuote"
      }}
      initialState={{
        quoteId: 1,
        color: "blue"
      }}
      derivedState={{
        quoteLengths: (getState, quoteId) => {
          return getState("quotes", quoteId).description.length
        }
      }}
      middleware={[consoleLogger]}
    >
      <ErrorBoundary fallback={ErrorMessage}>
        <Suspense fallback={<p>Loading...</p>}>
          <CurrentQuote />
        </Suspense>
      </ErrorBoundary>
    </Store>
  )
}
1090960
function(app, options) {
        return {
            server: (function() {
                var httpModule = serverUtils.getHttpModule(options);

                if (
                    options.get("scheme") === "https" ||
                    options.get("httpModule") === "http2"
                ) {
                    var opts = serverUtils.getHttpsOptions(options);
                    return httpModule.createServer(opts.toJS(), app);
                }

                return httpModule.createServer(app);
            })(),
            app: app
        };
    }
457165
function EasyMySQL(config)
{
	this.debug = config.error_debug || false;

	if(db)
		db.configure(config);
}
1244452
def init_app(self, app, **kwargs):
        """"""
        self.init_db(app, **kwargs)

        app.config.setdefault('ALEMBIC', {
            'script_location': pkg_resources.resource_filename(
                'invenio_db', 'alembic'
            ),
            'version_locations': [
                (base_entry.name, pkg_resources.resource_filename(
                    base_entry.module_name, os.path.join(*base_entry.attrs)
                )) for base_entry in pkg_resources.iter_entry_points(
                    'invenio_db.alembic'
                )
            ],
        })

        self.alembic.init_app(app)
        app.extensions['invenio-db'] = self
        app.cli.add_command(db_cmd)
759380
function buildDbConfig(appName, config) {
    var dbDriver = fetchFromConfig(appName, config, 'dbDriver') || 'mongo';
    var defaultPort = dbDriver === 'mongo' ? 27017 : 5432;
    return {
        dbName:         fetchFromConfig(appName, config, 'dbName'),
        dbPath:         fetchFromConfig(appName, config, 'dbPath'),
        dbDriver:       dbDriver,
        dbType:         fetchFromConfig(appName, config, 'dbType')        || 'mongo',
        dbUser:         fetchFromConfig(appName, config, 'dbUser')        || 'nodejs',
        dbPassword:     fetchFromConfig(appName, config, 'dbPassword')    || null,
        dbConnections:  parseInt(fetchFromConfig(appName, config, 'dbConnections')) || 20,
        dbConcurrency:  parseInt(fetchFromConfig(appName, config, 'dbConcurrency')) || 5,
        dbConnectionTimeout: parseInt(fetchFromConfig(appName, config, 'dbConnectionTimeout')) || 60000,
        dbPort: fetchFromConfig(appName, config, 'dbPort') || defaultPort,
        knexDebug: fetchFromConfig(appName, config, 'knexDebug') || false
    };
}
499411
function serializeApp(app, callback) {
	if(!app || typeof app.createSessionObject !== 'function') {
		throw new Error('Expects a valid qsocks app connection')
	};
		
	var appObj = {};
	
	// Generic Lists to be iterated over for qAppObjectListDef
	var LISTS = [{'sheets': 'sheet'}, {'stories': 'story'}, {'masterobjects': 'masterobject'}, {'appprops': 'appprops'}];
	
	// Property name mapping against methods
	var METHODS = {
		dimensions: getDimensions,
		measures: getMeasures,
		bookmarks: getBookmarks,
		embeddedmedia: getMediaList,
		snapshots: getSnapshots,
		fields: getFields,
		dataconnections: getConnections,
		variables: getVariables
	};
	
	return app.getAppProperties().then(function (properties) { 
			return appObj.properties = properties; 
		})
		.then(function () {
			return app.getScript().then(function (script) { return appObj.loadScript = script; })
		})
		.then(function () {
			return Promise.all(LISTS.map(function (d, i) {
				return getList(app, d[Object.keys(d)[0]])
			})).then(function (data) { return LISTS.forEach(function(d, y) { appObj[Object.keys(d)[0]] = data[y] }); });
		})
		.then(function () {	
			return Promise.all(Object.keys(METHODS).map(function(key, i) {
				return METHODS[key](app).then(function(data) { return appObj[key] = data });
			}));		
		})
		.then(function() {
			return appObj;
		})
		
}
1369442
function _initStorage$1(options) {
    var self = this;
    var dbInfo = {
        db: null
    };

    if (options) {
        for (var i in options) {
            dbInfo[i] = typeof options[i] !== 'string' ? options[i].toString() : options[i];
        }
    }

    var dbInfoPromise = new Promise$1(function (resolve, reject) {
        // Open the database; the openDatabase API will automatically
        // create it for us if it doesn't exist.
        try {
            dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);
        } catch (e) {
            return reject(e);
        }

        // Create our key/value table if it doesn't exist.
        dbInfo.db.transaction(function (t) {
            createDbTable(t, dbInfo, function () {
                self._dbInfo = dbInfo;
                resolve();
            }, function (t, error) {
                reject(error);
            });
        }, reject);
    });

    dbInfo.serializer = localforageSerializer;
    return dbInfoPromise;
}
176329
function saveSchemas(app) {
    var keys = Object.keys(DependenciesMap);
    if (keys.length == 0) {
        _l('Default data saved...');
        event.emit(COMPLETED_EVENT);
        return;
    }
    HandlerArray = [];
    var errFlag = true;
    keys.forEach(function (k) {
        dependenciesExists(k) && HandlerArray.push(getHandler(app, k, PluginsData[k]));

    });
    async.series(HandlerArray, function (err, end) {
        if (err)
            throw err;

        saveSchemas(app);
    });
}
443173
function (dbname, callback) {
    var executeDB = load('db');
    this.internals.argv._.push(dbname);
    this.internals.mode = 'create';
    return Promise.fromCallback(
      function (callback) {
        executeDB(this.internals, this.config, callback);
      }.bind(this)
    ).asCallback(callback);
  }