aaronpowell/db.js — pull request #41 by orthecreedence (2013-10-17 23:40:03+00:00)
Title: Adding .modify() to query functions for atomic, in-place updates

Also updated README to reflect changes, give examples.

`.modify()` allows specifying atomic changes to a collection of results returned by a query. It returns the same results that it modifies (but with the modifications applied) to the deferred/promise (so it's somewhat like Mongo's findAndModify command).

Examples:

```javascript
// grab all recently modified users, and atomically update their modified status to `false`
mydb.users.query('modified')
.only(true)
.modify({modified: false}) // atomically set modified to `false`
.execute()
.done(function(results) {
// results is a collection of all modified users
});

// use a function in a `modify` object value to specify the new value
mydb.profiles.query('name')
.lowerBound('zazi')
.modify({views: function(profile) { return profile.views + 1; }})
.execute()
.done(function(results) {
// now have all profiles with a name above 'zazi', with update profile view count
})
```

I'm not married to the name `modify` but thought it fit in this scenario. Feel free to give any notes, just started using db.js not long ago...tried to follow all your conventions =]