Skip to content

Instantly share code, notes, and snippets.

@taylonr
Created May 12, 2014 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taylonr/38ccb31aafbbb4bae813 to your computer and use it in GitHub Desktop.
Save taylonr/38ccb31aafbbb4bae813 to your computer and use it in GitHub Desktop.
underscore query
var _ = require('lodash'),
ActivityController = require('../../../controllers/activity.controller'),
FakeDatabase = [
{userId: '123', Name: 'First Activity', Records: [{Date: new Date(2014, 1, 1)}]},
{userId: '123', Name: 'Second Activity', Records: [{Date: new Date(2014, 2, 1)}]}];
require('underscore-query')(_);
ActivityController.Activity.find = function(findObject, callback){
var activities = _.query(FakeDatabase, findObject);
callback(null, activities);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment