index.js
function loadDocument (directory, callback) {
  var docPath = path.resolve(directory, '_design.js')
  fs.stat(docPath, function (err, stat) {
    if (err) return callback.call(null, err);
    if (stat.isFile()) {
      var document = require(docPath);
      return callback.call(null, null, document);
    }
    return callback.call(null, new Error('No _design.js file found!'));
  });
}
function loadDocument (directory, callback) {
  var docPath = path.resolve(directory, '_design.js')
  fs.stat(docPath, function (err, stat) {
    if (err) return callback.call(null, err);
    if (stat.isFile()) {
      var document = require(docPath);
      return callback.call(null, null, document);
    }
    return callback.call(null, new Error('No _design.js file found!'));
  });
}
function loadDocument ( directory , callback ) { var docPath = path . resolve ( directory , '_design.js' ) fs . stat ( docPath , function ( err , stat ) { if ( err ) return callback . call ( null , err ) ; if ( stat . isFile ( ) ) { var document = require ( docPath ) ; return callback . call ( null , null , document ) ; } return callback . call ( null , new Error ( 'No _design.js file found!' ) ) ; } ) ; }
Load a design document from the _design.js directive
within a specified directory.

@param {string} directory
@param {function} callback (err, document)
Load a design document from the _design . js directive within a specified directory .