rudiment.js
function(doc) {
      if (!this.isValid(doc)) {
        return Promise.resolve(false);
      }

      var props = pick(doc, this._uniq);
      if (!Object.keys(props).length) {
        return Promise.resolve(true);
      }

      return this._dbApi.isAdmissible(doc, props);
    }
function(doc) {
      if (!this.isValid(doc)) {
        return Promise.resolve(false);
      }

      var props = pick(doc, this._uniq);
      if (!Object.keys(props).length) {
        return Promise.resolve(true);
      }

      return this._dbApi.isAdmissible(doc, props);
    }
function ( doc ) { if ( ! this . isValid ( doc ) ) { return Promise . resolve ( false ) ; } var props = pick ( doc , this . _uniq ) ; if ( ! Object . keys ( props ) . length ) { return Promise . resolve ( true ) ; } return this . _dbApi . isAdmissible ( doc , props ) ; }
Check if a proposed document is admissible into the database

A document is admissible if it passes the valid predicate, and no other
document in the database is already using its unique keys.

@param {Object} doc - a document to test
@return {Promise}
Check if a proposed document is admissible into the database