function()

in app/api-service-broker/app.js [129:156]


      function(cb) {
        Site.count({})
          .then(function(total) {
            console.log(`Sites present: `, total);
            if (total === 0) {
              var sites = fs.readFileSync(`./data/sites.json`, `utf8`);
              var newSites = JSON.parse(sites);
              Site.create(newSites)
                .then(function(docs) {
                  console.log(`Inserted Sites Count: `, docs.length);
                  return null;
                })
                .catch(function(err) {
                  console.log(`Error creating sites: `, err);
                })
                .finally(function() {
                  return null;
                });
            }
            return null;
          })
          .catch(function(err) {
            console.log(err);
          })
          .finally(function() {
            cb(null);
          });
      },