lib/common/model.js
function (criteria) {
            var identity = this.identity;

            return this.findOne(criteria).then(function (record) {
                if (!record) {
                    throw new Errors.NotFoundError(
                        'Could not find %s with criteria %j.'.format(
                            pluralize.singular(identity),
                            criteria
                        ), {
                            criteria: criteria,
                            collection: identity
                        });
                }

                return record;
            });
        }
function (criteria) {
            var identity = this.identity;

            return this.findOne(criteria).then(function (record) {
                if (!record) {
                    throw new Errors.NotFoundError(
                        'Could not find %s with criteria %j.'.format(
                            pluralize.singular(identity),
                            criteria
                        ), {
                            criteria: criteria,
                            collection: identity
                        });
                }

                return record;
            });
        }
function ( criteria ) { var identity = this . identity ; return this . findOne ( criteria ) . then ( function ( record ) { if ( ! record ) { throw new Errors . NotFoundError ( 'Could not find %s with criteria %j.' . format ( pluralize . singular ( identity ) , criteria ) , { criteria : criteria , collection : identity } ) ; } return record ; } ) ; }
Find a single document via criteria and resolve it, otherwise
reject with a NotFoundError.
Find a single document via criteria and resolve it otherwise reject with a NotFoundError .