Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated readme

  • Loading branch information...
commit f8a0ce45c071afe7b3e5e4ec4b1fb7c9e95d94e6 1 parent f496efd
@rpoole rpoole authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 README.md
View
26 README.md
@@ -72,6 +72,7 @@ You can install using Node Package Manager (npm):
* [update](#modelUpdate)
* [delete](#modelDelete)
* [getById](#modelGetById)
+ * [defineClause](#modelDefineClause)
* [onSave](#modelOnSave)
* [onLoad](#modelOnLoad)
* [Associated Object Properties](#associatedObjectProperties)
@@ -585,6 +586,31 @@ Person.getById(connection, 1, function(err, person) {
// person is the person with id equal to 1. Or null if not found
});
```
+<a name="modelDefineClause" />
+### Model.defineClause(clauseName, clauses)
+
+Creates a custom method that is a composition of clauses. Only supports
+clauses - where, orderBy, etc. Trying to chain a method that returns results
+(all, first, min, etc.) will not work.
+
+__Arguments__
+
+ * clauseName - The name of the clause to be attached to the model
+ * clauses - The object describing the clauses. Follows a name: arguments
+ structure.
+
+__Example__
+```javascript
+Person.defineClause('clauseName', {
+ where: 'id > 5',
+ orderBy: 'id',
+ limit: 5,
+});
+
+Person.clauseName().all(connection, function(err, people) {
+ // All the people with id > 5, ordered by id and limited to 5
+});
+```
<a name="modelOnSave" />
### Model.onSave(obj, connection, callback)
Please sign in to comment.
Something went wrong with that request. Please try again.