Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Build a REST API With Express Modeling Data for the API Getting More from Mongoose

Michael Liendo
Michael Liendo
15,326 Points

Fix: How to correctly configure the findSize method

at about 10:45 the task is left up to us to test the findSize(String,callback) method.

Just wanted to let others know how to get it set up per the mongoose Docs since the video outline didn't work for me.

var AnimalSchema = new Schema({
.
.
.
size: {type: String]
});

AnimalSchema.static('findSize', function(size, callback) {
  return this.find({size:size},callback);
});

Animal.findSize('big',function(err, animals) {
    //code