flatiron/resourceful — Issue #24: Broken `find` in couchdb
Author: pkumar
Created: 2011-12-04 13:21:55+00:00
State: open

```
var resourceful = require('../lib/resourceful');

var Creature = resourceful.define('creature', function () {
this.use('couchdb', {database: 'flatiron'});
this.property('diet');
this.property('vertebrate', Boolean);
this.property('belly', Array);

this.prototype.feed = function (food) {
this.belly.push(food);
};
});

Creature.find({diet: 'carnivor'}, function (err, c) {
if (err) throw err;
console.log(c);
});
```

Running the above code gives the following error

```

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'apply' of undefined
at /home/pkumar/Coding/git/flatiron/resourceful/lib/resourceful/resource.js:160:29
at Function.runBeforeHooks (/home/pkumar/Coding/git/flatiron/resourceful/lib/resourceful/resource.js:55:12)
at Function._request (/home/pkumar/Coding/git/flatiron/resourceful/lib/resourceful/resource.js:106:8)
at Function.find (/home/pkumar/Coding/git/flatiron/resourceful/lib/resourceful/resource.js:262:15)
at Object. (/home/pkumar/Coding/git/flatiron/resourceful/examples/creature-function.js:14:10)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
at Array. (module.js:421:10)
```