lib/bootstrap.js
function load(data, site) {
  let promiseComponentsOps, promisePagesOps, promiseUrisOps, promiseListsOps, promiseUsersOps,
    prefix = site.prefix,
    compData = applyPrefix(data, site);

  promiseListsOps = saveObjects(`${prefix}/_lists/`, compData._lists, getPutOperation);
  promiseUrisOps = saveBase64Strings(`${prefix}/_uris/`, compData._uris, getPutOperation);
  _.each(compData._uris, function (page, uri) {
    log('info', `bootstrapped: ${uri} => ${page}`);
  });
  promiseComponentsOps = saveWithInstances(`${prefix}/_components/`, compData._components, function (name, item) {
    return bluebird.join(
      dbOps.getPutOperations(components.cmptPut, name, _.cloneDeep(item), locals.getDefaultLocals(site))
    ).then(_.flatten);
  });
  promisePagesOps = saveObjects(`${prefix}/_pages/`, compData._pages, (name, item) => [getPutOperation(name, item)]);
  promiseUsersOps = saveObjects('', compData._users, (name, item) => [getPutOperation(`/_users/${encode(`${item.username}@${item.provider}`)}`, item)]);

  /* eslint max-params: ["error", 5] */
  return bluebird.join(promiseComponentsOps, promisePagesOps, promiseUrisOps, promiseListsOps, promiseUsersOps, function (componentsOps, pagesOps, urisOps, listsOps, userOps) {
    const flatComponentsOps = _.flatten(componentsOps),
      ops = flatComponentsOps.concat(_.flattenDeep(pagesOps.concat(urisOps, listsOps, userOps)));

    return db.batch(ops, { fillCache: false, sync: false });
  });
}
function load(data, site) {
  let promiseComponentsOps, promisePagesOps, promiseUrisOps, promiseListsOps, promiseUsersOps,
    prefix = site.prefix,
    compData = applyPrefix(data, site);

  promiseListsOps = saveObjects(`${prefix}/_lists/`, compData._lists, getPutOperation);
  promiseUrisOps = saveBase64Strings(`${prefix}/_uris/`, compData._uris, getPutOperation);
  _.each(compData._uris, function (page, uri) {
    log('info', `bootstrapped: ${uri} => ${page}`);
  });
  promiseComponentsOps = saveWithInstances(`${prefix}/_components/`, compData._components, function (name, item) {
    return bluebird.join(
      dbOps.getPutOperations(components.cmptPut, name, _.cloneDeep(item), locals.getDefaultLocals(site))
    ).then(_.flatten);
  });
  promisePagesOps = saveObjects(`${prefix}/_pages/`, compData._pages, (name, item) => [getPutOperation(name, item)]);
  promiseUsersOps = saveObjects('', compData._users, (name, item) => [getPutOperation(`/_users/${encode(`${item.username}@${item.provider}`)}`, item)]);

  /* eslint max-params: ["error", 5] */
  return bluebird.join(promiseComponentsOps, promisePagesOps, promiseUrisOps, promiseListsOps, promiseUsersOps, function (componentsOps, pagesOps, urisOps, listsOps, userOps) {
    const flatComponentsOps = _.flatten(componentsOps),
      ops = flatComponentsOps.concat(_.flattenDeep(pagesOps.concat(urisOps, listsOps, userOps)));

    return db.batch(ops, { fillCache: false, sync: false });
  });
}
function load ( data , site ) { let promiseComponentsOps , promisePagesOps , promiseUrisOps , promiseListsOps , promiseUsersOps , prefix = site . prefix , compData = applyPrefix ( data , site ) ; promiseListsOps = saveObjects ( ` ${ prefix } ` , compData . _lists , getPutOperation ) ; promiseUrisOps = saveBase64Strings ( ` ${ prefix } ` , compData . _uris , getPutOperation ) ; _ . each ( compData . _uris , function ( page , uri ) { log ( 'info' , ` ${ uri } ${ page } ` ) ; } ) ; promiseComponentsOps = saveWithInstances ( ` ${ prefix } ` , compData . _components , function ( name , item ) { return bluebird . join ( dbOps . getPutOperations ( components . cmptPut , name , _ . cloneDeep ( item ) , locals . getDefaultLocals ( site ) ) ) . then ( _ . flatten ) ; } ) ; promisePagesOps = saveObjects ( ` ${ prefix } ` , compData . _pages , ( name , item ) => [ getPutOperation ( name , item ) ] ) ; promiseUsersOps = saveObjects ( '' , compData . _users , ( name , item ) => [ getPutOperation ( ` ${ encode ( ` ${ item . username } ${ item . provider } ` ) } ` , item ) ] ) ; /* eslint max-params: ["error", 5] */ return bluebird . join ( promiseComponentsOps , promisePagesOps , promiseUrisOps , promiseListsOps , promiseUsersOps , function ( componentsOps , pagesOps , urisOps , listsOps , userOps ) { const flatComponentsOps = _ . flatten ( componentsOps ) , ops = flatComponentsOps . concat ( _ . flattenDeep ( pagesOps . concat ( urisOps , listsOps , userOps ) ) ) ; return db . batch ( ops , { fillCache : false , sync : false } ) ; } ) ; }
Load items into db from config object
@param {object} data
@param {object} site
@returns {Promise}
Load items into db from config object