Skip to content

Instantly share code, notes, and snippets.

@korczis
Created August 4, 2012 22:01
Show Gist options
  • Save korczis/3260246 to your computer and use it in GitHub Desktop.
Save korczis/3260246 to your computer and use it in GitHub Desktop.
Node.js + Geddy + MongoDB + search (not working)
this.index = function (req, resp, params) {
var self = this;
// Limit in params?
var limit = 100; // default limit
if(params.limit) {
limit = parseInt(params.limit);
}
// Offset in params?
var offset = 0; // default offset
if(params.offset) {
offset = parseInt(params.offset);
}
// TODO: Get total count
var count = -1;
// Query in params?
var query = {};
if(params.q) {
query = { title: params.q }
} else if (params.fts) {
query = { fts: ["adorable", "teen", "gets", "fucked"] };
}
// Fetch data
geddy.model.adapter.Movie.all(query
, {sort: {title: 1}, limit: limit, skip: offset}
, function(err, data) {
self.respond({params: params
, movies: data
, count: count
, limit: limit
, offset: offset
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment