How to do a findAll using mongoosejs?

This is my LinkSchema:

var LinkSchema = new Schema({

  user: ObjectId,

  text: {
      type: String,
      validate: [required,"Text is required"],
      index: {unique: true}
    },
    body: {
        type: String,
        validate: [required, 'Body is required'],
        index: { unique: true }
    },
    createdAt: {
        type: Date,
        'default': Date.now
    }
});

This is my getLink:

LinkSchema.statics.getLink = function(apiKey,fn){

    var query = link.find('link.user.apiKey': apiKey);

    query.exec(function (err, links) {
      if (err) return handleError(err);
        res.send(items);

    });
}

Error:

Unexpected Token':'  -> var query = link.find('link.user.apiKey': apiKey);

I suppose I am doing the find() of mongoosejs wrong. How do I fix this?

You can simply do this:

var Link = db.model('Link', LinkSchema);
Link.find({}, function(err, results) {
    // res.send(results); for example.
});

The first argument of the find function is the query. For example, if you want to search all Link with body equals to blablabla:

Link.find({body: 'blablabla'}, function(err, results) {
    // res.send(results); for example.
});