balderdashy/waterline — pull request #509 by jasonsims (2014-07-02 20:07:41+00:00)
Title: Add `.select()` and `.prune()` methods

This PR adds the ability to apply projections to waterline queries. It's an extension of the work accomplished in #162 by adding flexibility for how selection arguments are supplied as well as exclusions via `.prune()`. With this change, the adapters will always receive a standardized selection criteria object which they can process as needed for their specific query language. Here's an example of this object:
```js
// User.find().select('name', 'age').exec(cb);
select: { name: 1, age: 1 }

// User.find().prune('name', 'age').exec(cb);
select: { name: 0, age: 0 }
```

Usage examples:
```js
// Include only
User.find().select('name', 'age').exec(cb);
User.find().select(['name', 'age']).exec(cb);
User.find().select({name: 1, age: 1}).exec(cb);

// Exclusion
User.find().prune('name', 'age').exec(cb);
User.find().prune(['name', 'age']).exec(cb);
User.find().prune({name: 1, age: 1}).exec(cb);
```

fixes #73 - This PR is still pending the addition of corresponding tests which I'll add shortly