Пример #1
0
const prepare = doc => {
  console.log('Checking if already published...');
  doc._id = stagingDocId;
  doc._rev = undefined;
  return stagingDb.get(stagingDocId)
    .then(current => {
      console.log(`Exising release found - updating...`);
      doc._rev = current._rev;
      return doc;
    })
    .catch(err => {
      if (err.status === 404) {
        console.log(`No exising release found - creating...`);
        return doc;
      }
      throw err;
    });
};
Пример #2
0
 DBs[dbname].autoIncrease = function () {
   return autoIncreaseCount
     .get(dbname)
     .then(function (doc) {
       return new Promise(function (resolve) {
         autoIncreaseCount.put(doc).then(function (result) {
           if (result.ok) {
             resolve(doc.num)
           }
         })
       })
     }).catch(function (err) {
       if (err.status === 409) return DB.autoIncrease()
       return autoIncreaseCount.put({
         _id: dbname,
         num: 1
       }).then(function () {
         return 1
       })
     })
 }
Пример #3
0
 .then(() => ddb.get('count'))
Пример #4
0
const get = () => {
  console.log(`Getting "${testingDocId}"...`);
  return testingDb.get(testingDocId, { attachments: true });
};