Skip to content

Commit

Permalink
Updated README with new preprocessor API
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Dec 3, 2013
1 parent b1173c8 commit 1227c58
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,33 @@ TODO
TODO

## Preprocessing Framework
The preprocessing framework allows Iridium to convert values from a form better suited to your database into a form more suitable for your application in an entirely transparent manner. This is acomplished through the use of a number of preprocessors which run in the following order when retrieving an object from the database, their order is reversed when pushing an object to the database.
The preprocessing framework allows Iridium to convert values from a form better suited to your database into a form more suitable for your application in an entirely transparent manner. This is acomplished through the use of a number of preprocessors which run when retrieving an object from the database, their order is reversed when pushing an object to the database.

### Transforms
### Conversions
The transforms framework provides a low-level means to convert from one value type to another by means of up/down conversion functions. The up functions are used to convert the value before it is sent UPstream to the database, while down functions are used to convert the database value into the DOWNstream value used by your application.

```javascript
var model = new Model(db, 'modelName', modelSchema, {
preprocessors: [new Database.Convert({
property: {
$up: function(value) { return convertedValueForDatabase; },
$down: function(value) { return convertedValueFromDatabase }
}
})]
});
```

### Renames
The renames framework allows you to access properties in a manner better suited to your application while keeping the same schema on the database side. This comes in handy when using the *_id* field for fields such as a user's username.

```javascript
var model = new Model(db, 'modelName', modelSchema, {
preprocessors: [new Database.Rename({
_id: 'id'
})]
});
```

## Credits
Thanks to [Tadahiro Ishisaka](https://github.com/ishisaka) for his brilliant [nodeintellisense](https://github.com/ishisaka/nodeintellisense) library, it has been used as the basis for IntelliSense support within this module.

Expand Down

0 comments on commit 1227c58

Please sign in to comment.