-
Notifications
You must be signed in to change notification settings - Fork 19
/
api.html
7 lines (7 loc) · 52.6 KB
/
api.html
1
2
3
4
5
6
7
<head><title>Tower.js - Small components for building hardcore apps.</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:300,400"><link rel="stylesheet" href="public/css/bootstrap.min.css"><link rel="stylesheet" href="public/css/bootstrap-responsive.min.css"><link rel="stylesheet" href="public/css/index.css"><script type="text/javascript" src="public/js/build.js"></script><script>var jQuery = $ = require("component-jquery");
var mainApp = require('tower-website/public/js/index');
mainApp();</script></head><body data-scope="body"><div id="wrapper"><header class="container-fluid"><div class="row-fluid"><ul class="span12"><li class="logo"><a href="./"><img src="public/img/logo.png" alt="Tower"></a></li><li class="pull-right"><ul><li><a href="guide" title="Guide">Guide</a></li><!--<li>
<a href="api" title="API Docs">API</a>
</li>--><li><a href="https://github.com/tower/tower" title="GitHub Repos">GitHub</a></li></ul></li></ul></div></header><section id="body" data-content="" class="container-fluid"><div><div class="row-fluid api-page"><div class="content span9"><div id="api"><div id="adapter-module" class="module"><h2>adapter</h2><div class="module-content"><div id="adapter-module-classes"><section id="class-adapter-Adapter" class="klass"><h3>Adapter Class:</h3><div class="description"><p>Class representing an abstraction over remote services and databases.</p></div><div class="class-constructor"><h4>Constructor: Adapter(name)</h4><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">An adapter name.</div></li></ul></div></div><h4>Methods:</h4><div id="class-adapter-Adapter"><section id="class-method-adapter-Adapter-query" class="method"><h3>query() <span class="type">Mixed</span></h3><div class="description"><p>Start a query against this adapter.</p></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Mixed</span>: <span class="description">Whatever the implementation of the use function attribute returns.</span></div></div></section><section id="class-method-adapter-Adapter-use" class="method"><h3>use(name)</h3><div class="description"><p>Use database/connection (config).</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">An adapter name.</div></li></ul></div></section><section id="class-method-adapter-Adapter-connection" class="method"><h3>connection(name, options)</h3><div class="description"><p>Define connection settings.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">An adapter name.</div></li><li><span class="param-name">options</span> <span class="type">Object</span><div class="param-description">Adapter options.</div></li></ul></div></section><section id="class-method-adapter-Adapter-type" class="method"><h3>type(name) <span class="type">Adapter</span><span class="chainable">chainable</span></h3><div class="description"><p>Datatype serialization.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">An adapter name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Adapter</span></div></div></section><section id="class-method-adapter-Adapter-serializer" class="method"><h3>serializer(name) <span class="type">Adapter</span><span class="chainable">chainable</span></h3><div class="description"><p>Delegate to<code>type</code>.</p><p>XXX: This may just actually become the<code>type</code>object itself.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">An adapter name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Adapter</span></div></div></section><section id="class-method-adapter-Adapter-to" class="method"><h3>to(fn) <span class="type">Adapter</span><span class="chainable">chainable</span></h3><div class="description"><p>Set a<code>to</code>relationship.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function executed on `to` query.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Adapter</span></div></div></section><section id="class-method-adapter-Adapter-from" class="method"><h3>from(fn) <span class="type">Adapter</span><span class="chainable">chainable</span></h3><div class="description"><p>Set a<code>from</code>relationship.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function executed on `from` query.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Adapter</span></div></div></section><section id="class-method-adapter-Adapter-exec" class="method"><h3>exec(query, fn) <span class="type">Adapter</span><span class="chainable">chainable</span></h3><div class="description"><p>Main Adapter function the query object executes which you need to implement on your own adapter.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">query</span> <span class="type">Query</span><div class="param-description">A query object.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Adapter implementation function.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Adapter</span></div></div></section><section id="class-method-adapter-Adapter-self" class="method"><h3>self() <span class="type">Adapter</span><span class="chainable">chainable</span></h3><div class="description"><p>Reset the context to<code>this</code>.</p></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Adapter</span></div></div></section></div></section></div><h2>Methods:</h2><div id="adapter-module-methods"><section id="method-adapter-adapter" class="method"><h3>adapter.adapter(name) <span class="type">Adapter</span></h3><div class="description"><p>Lazily get an adapter instance by<code>name</code>.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">An adapter name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Adapter</span>: <span class="description">An adapter.</span></div></div></section></div></div></div><div id="cookbook-module" class="module"><h2>cookbook</h2><div class="module-content"></div></div><div id="expression-module" class="module"><h2>expression</h2><div class="module-content"><h2>Methods:</h2><div id="expression-module-methods"><section id="method-expression-expression" class="method"><h3>expression.expression(val) <span class="type">Function</span></h3><div class="description"><p>Parse a directive expression.</p><p>XXX: Maybe there are "named" expressions later.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">val</span> <span class="type">String</span><div class="param-description">The directive expression string.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Function</span>: <span class="description">fn Expression to evaluate</span></div></div></section></div></div></div><div id="route-module" class="module"><h2>route</h2><div class="module-content"><div id="route-module-classes"><section id="class-route-Route" class="klass"><h3>Route Class:</h3><div class="description"><p>Class representing a route.</p></div><div class="class-constructor"><h4>Constructor: Route(options)</h4><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">options</span> <span class="type">Object</span><div class="param-description">Route options.</div></li></ul></div></div><h4>Methods:</h4><div id="class-route-Route"><section id="class-method-route-Route-param" class="method"><h3>param(name, type) <span class="type">Route</span><span class="chainable">chainable</span></h3><div class="description"><p>Specify how to parse a URL parameter.</p><p>This is roughly equivalent to an attribute<br>on a model, e.g.<code>model('Post').attr(x)</code>.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">A param name.</div></li><li><span class="param-name">type</span> <span class="type">String</span><div class="param-description">A param type.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Route</span></div></div></section><section id="class-method-route-Route-type" class="method"><h3>type(type) <span class="type">Route</span><span class="chainable">chainable</span></h3><div class="description"><p>The accepted HTTP methods.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">type</span> <span class="type">Object</span><div class="param-description"></div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Route</span></div></div></section><section id="class-method-route-Route-use" class="method"><h3>use(fn) <span class="type">Route</span><span class="chainable">chainable</span></h3><div class="description"><p>Add a function to process the incoming request.</p><p>If called multiple times they will be executed<br>in sequence. They can be asynchronous, just<br>pass a<code>done</code>argument to<code>fn</code>.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">A function to process the incoming request.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Route</span></div></div></section><section id="class-method-route-Route-accept" class="method"><h3>accept(arguments) <span class="type">Route</span><span class="chainable">chainable</span></h3><div class="description"><p>Accepted<code>Content-Type</code>s.</p><p>If not specified, it will accept any.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">arguments</span> <span class="type">Arguments</span><div class="param-description">The default JavaScript function argument list.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Route</span></div></div></section><section id="class-method-route-Route-format" class="method"><h3>format(name, fn) <span class="type">Route</span><span class="chainable">chainable</span></h3><div class="description"><p>Specify how to format the data for the response.</p><p>Example:</p><p>route('/', 'index')<br>.format('json', function(content){<br>content.render({ hello: 'world' });<br>})</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">The data format name.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">The function to respond to the data format.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Route</span></div></div></section><section id="class-method-route-Route-action" class="method"><h3>action(name, fn) <span class="type">Route</span><span class="chainable">chainable</span></h3><div class="description"><p>Add an action to the actions list.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">Action name.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function to handle action.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Route</span></div></div></section><section id="class-method-route-Route-self" class="method"><h3>self() <span class="type">Route</span><span class="chainable">chainable</span></h3><div class="description"><p>Clear the chainable API context.</p></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Route</span></div></div></section><section id="class-method-route-Route-handle" class="method"><h3>handle(context, next) <span class="type">Boolean</span></h3><div class="description"><p>Process a request given a context.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">context</span> <span class="type">Context</span><div class="param-description">A context.</div></li><li><span class="param-name">next</span> <span class="type">Function</span><div class="param-description">Function used to handle non-matching context path and params.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Boolean</span>: <span class="description">true if a request can be processed, else falsy.</span></div></div></section><section id="class-method-route-Route-parseParams" class="method"><h3>parseParams(context)</h3><div class="description"><p>Parse the params from a given context.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">context</span> <span class="type">Context</span><div class="param-description">A context.</div></li></ul></div></section></div></section></div><h2>Methods:</h2><div id="route-module-methods"><section id="method-route-route" class="method"><h3>route.route(name, path, options) <span class="type">Route</span></h3><div class="description"><p>Find or define a route.</p><p>Examples:</p><p>route('/posts', 'posts.index')<br>route('/posts', 'posts.index', 'GET')<br>route('/posts', 'posts.index', { method: 'GET' })<br>route('/posts', { name: 'posts.index', method: 'GET' })<br>route({ path: '/posts', name: 'posts.index', method: 'GET' })<br>route('posts.index')</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">Route name.</div></li><li><span class="param-name">path</span> <span class="type">String</span><div class="param-description">Route path delimited with periods `.`.</div></li><li><span class="param-name">options</span> <span class="type">Object</span><div class="param-description">Route options.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Route</span>: <span class="description">Route instance.</span></div></div></section></div></div></div><div id="type-module" class="module"><h2>type</h2><div class="module-content"><div id="type-module-classes"><section id="class-type-Type" class="klass"><h3>Type Class:</h3><div class="description"><p>Class representing a type.</p></div><div class="class-constructor"><h4>Constructor: Type(name, fn)</h4><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">A type name.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">A function added to a list of sanitizers that sanitizes the type.</div></li></ul></div></div><h4>Methods:</h4><div id="class-type-Type"><section id="class-method-type-Type-validator" class="method"><h3>validator(name, fn)<span class="chainable">chainable</span></h3><div class="description"><p>Add a validator function to a type.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">A validator name.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">A validator function.</div></li></ul></div></section><section id="class-method-type-Type-use" class="method"><h3>use(fn) <span class="type">Type</span><span class="chainable">chainable</span></h3><div class="description"><p>Sanitize functions to pass value through.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">A sanitizor function.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Type</span></div></div></section><section id="class-method-type-Type-sanitize" class="method"><h3>sanitize(val) <span class="type">Mixed</span></h3><div class="description"><p>Sanitize (or maybe<code>serialize</code>).</p><p>XXX: maybe rename to<code>cast</code>?</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">val</span> <span class="type">Mixed</span><div class="param-description">A value to sanitize.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Mixed</span>: <span class="description">The value sanitized.</span></div></div></section><section id="class-method-type-Type-serializer" class="method"><h3>serializer(name) <span class="type">Type</span><span class="chainable">chainable</span></h3><div class="description"><p>Seralizer object by name.</p><p>XXX: Maybe refactor into<code>tower/serializer</code>module.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">Object name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Type</span></div></div></section><section id="class-method-type-Type-to" class="method"><h3>to(fn) <span class="type">Type</span><span class="chainable">chainable</span></h3><div class="description"><p>Define how to serialize type from<br>JavaScript to external API/service request format.</p><p>XXX: to/out/request/serialize/format/use</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function to handle serialization.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Type</span></div></div></section><section id="class-method-type-Type-from" class="method"><h3>from(fn) <span class="type">Type</span><span class="chainable">chainable</span></h3><div class="description"><p>Define how to deserialize type from<br>external API/service request format to JavaScript.</p><p>XXX: from/in/response/deserialize</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function to handle deserialization.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Type</span></div></div></section></div></section></div><h2>Methods:</h2><div id="type-module-methods"><section id="method-type-type" class="method"><h3>type.type(name, fn) <span class="type">Type</span></h3><div class="description"><p>Define or get a type.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">Type name.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">A function added to a list of sanitizers that sanitizes the type.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Type</span>: <span class="description">A type instance.</span></div></div></section></div></div></div><div id="cli-module" class="module"><h2>cli</h2><div class="module-content"></div></div><div id="directive-module" class="module"><h2>directive</h2><div class="module-content"><h2>Methods:</h2><div id="directive-module-methods"><section id="method-directive-directive" class="method"><h3>directive.directive(name, fn) <span class="type">Directive</span></h3><div class="description"><p>Get/set directive function.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">The directive's name.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function called on directive definition.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Directive</span>: <span class="description">A `Directive` object.</span></div></div></section></div></div></div><div id="query-module" class="module"><h2>query</h2><div class="module-content"><div id="query-module-classes"><section id="class-query-Query" class="klass"><h3>Query Class:</h3><div class="description"><p>Class representing a query.</p></div><div class="class-constructor"><h4>Constructor: Query(name)</h4><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">A query instance's name.</div></li></ul></div></div><h4>Methods:</h4><div id="class-query-Query"><section id="class-method-query-Query-use" class="method"><h3>use(name) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>Explicitly tell the query what adapters to use.</p><p>If not specified, it will do its best to find<br>the adapter. If one or more are specified, the<br>first specified will be the default, and its namespace<br>can be left out of the resources used in the query<br>(e.g.<code>user</code>vs.<code>facebook.user</code>if<code>query().use('facebook').select('user')</code>).</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">Mixed</span><div class="param-description">Name of the adapter, or the adapter object itself.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-start" class="method"><h3>start(key, val) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>The starting table or record for the query.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description">The starting table or record name.</div></li><li><span class="param-name">val</span> <span class="type">Object</span><div class="param-description"></div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-select" class="method"><h3>select(key) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>Start a SELECT query.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description">A record or table name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-where" class="method"><h3>where(key) <span class="type">Query</span></h3><div class="description"><p>Add a WHERE clause.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description">A record or table property/column name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-incoming" class="method"><h3>incoming(key) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>In a graph database, the data pointing <em>to</em> this node.<br>In a relational/document database, the records with<br>a foreign key pointing to this record or set of records.</p><p>Example:</p><p>query().start('users')<br>.incoming('friends')<br>.incoming('friends');</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description">Name of the data coming to the start node.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-outgoing" class="method"><h3>outgoing(key) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>In a graph database, the data pointing <em>from</em> this node.<br>In a relational/document database, the record this<br>record points to via its foreign key.</p><p>Example:</p><p>query().start('users')<br>.outgoing('friends')<br>.outgoing('friends');</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description">Name of the data going out from the start node.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-as" class="method"><h3>as(key) <span class="type">Query</span></h3><div class="description"><p>What the variable should be called for the data returned.<br>References the previous item in the query.</p><p>Example:</p><p>query().start('users').as('people');</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description">The data's new variable name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-contains" class="method"><h3>contains(val) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>Check if the value exists within a set of values.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">val</span> <span class="type">Object</span><div class="param-description">The constraint value.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-create" class="method"><h3>create(data, fn) <span class="type">Mixed</span></h3><div class="description"><p>Create one or more records.</p><p>This is different from the other actions<br>in that it can take data (records) as arguments.</p><p>Example:</p><p>query()<br>.use('memory')<br>.select('post')<br>.create({ title: 'Foo' }, function(err, post){</p><pre><code> });
</code></pre></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">data</span> <span class="type">Object</span><div class="param-description">Data record.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function to be executed on record creation.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Mixed</span>: <span class="description">Whatever `fn` returns on the `create` action.</span></div></div></section><section id="class-method-query-Query-update" class="method"><h3>update(data, fn) <span class="type">Mixed</span></h3><div class="description"><p>Update one or more records.</p><p>This is different from the other actions<br>in that it can take data (records) as arguments.</p><p>Example:</p><p>query()<br>.use('memory')<br>.select('post')<br>.update({ title: 'Foo' }, function(err, post){</p><pre><code> });
</code></pre></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">data</span> <span class="type">Object</span><div class="param-description">Data record.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function to be executed on record update.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Mixed</span>: <span class="description">Whatever `fn` returns on the `update` action.</span></div></div></section><section id="class-method-query-Query-first" class="method"><h3>first(fn)</h3><div class="description"><p>Return the first record that matches the query pattern.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function to execute on records after `find` action finishes.</div></li></ul></div></section><section id="class-method-query-Query-last" class="method"><h3>last(fn)</h3><div class="description"><p>Return the last record that matches the query pattern.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function to execute on records after `find` action finishes.</div></li></ul></div></section><section id="class-method-query-Query-limit" class="method"><h3>limit(val) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>Add a record query LIMIT.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">val</span> <span class="type">Integer</span><div class="param-description">The record limit.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-page" class="method"><h3>page(val) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>Specify the page number.</p><p>Use in combination with<code>limit</code>for calculating<code>offset</code>.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">val</span> <span class="type">Integer</span><div class="param-description">The page number.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-offset" class="method"><h3>offset(val) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>Specify the offset.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">val</span> <span class="type">Integer</span><div class="param-description">The offset value.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-asc" class="method"><h3>asc(key) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>Sort ascending by<code>key</code>.</p><p>If the key is a property name, it will<br>be combined with the table/collection name<br>defined somewhere earlier in the query.</p><p>Example:</p><p>query().start('users').asc('createdAt');</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description">A property name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-desc" class="method"><h3>desc(key) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>Sort descending by<code>key</code>.</p><p>If the key is a property name, it will<br>be combined with the table/collection name<br>defined somewhere earlier in the query.</p><p>Example:</p><p>query().start('users').desc('createdAt');</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description">A property name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-explain" class="method"><h3>explain(fn) <span class="type">Query</span><span class="chainable">chainable</span></h3><div class="description"><p>A way to log the query criteria,<br>so you can see if the adapter supports it.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">The query criteria logging function</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span></div></div></section><section id="class-method-query-Query-clone" class="method"><h3>clone() <span class="type">Query</span></h3><div class="description"><p>Clone the current<code>Query</code>object.</p></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span>: <span class="description">A cloned `Query` object.</span></div></div></section><section id="class-method-query-Query-exec" class="method"><h3>exec(fn) <span class="type">Mixed</span></h3><div class="description"><p>Execute the query.<br>XXX: For now, only one query per adapter.<br>Later, you can query across multiple adapters</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function that gets called on adapter execution.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Mixed</span>: <span class="description">Whatever `fn` returns on execution.</span></div></div></section><section id="class-method-query-Query-validate" class="method"><h3>validate(fn)</h3><div class="description"><p>Validate the query on all adapters.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function called on query validation.</div></li></ul></div></section><section id="class-method-query-Query-subscribe" class="method"><h3>subscribe(fn)</h3><div class="description"><p>Subscribe to a type of query.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function executed on each subscriber output.</div></li></ul></div></section><section id="class-method-query-Query-query" class="method"><h3>query(name) <span class="type">Query</span></h3><div class="description"><p>Define another query on the parent scope.</p><p>XXX: wire this up with the resource (for todomvc).</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">A query name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span>: <span class="description">A `Query` object.</span></div></div></section></div></section><section id="class-query-Constraint" class="klass"><h3>Constraint Class:</h3><div class="description"><p>Class representing a query constraint.</p></div><div class="class-constructor"><h4>Constructor: Constraint(a, operator, b, start)</h4><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">a</span> <span class="type">String</span><div class="param-description">The left constraint.</div></li><li><span class="param-name">operator</span> <span class="type">String</span><div class="param-description">The constraint.</div></li><li><span class="param-name">b</span> <span class="type">String</span><div class="param-description">The right constraint.</div></li><li><span class="param-name">start</span> <span class="type">Object</span><div class="param-description">The starting object.</div></li></ul></div></div></section></div><h2>Methods:</h2><div id="query-module-methods"><section id="method-query-query" class="method"><h3>query.query(name) <span class="type">Query</span></h3><div class="description"><p>Wrap an array for chaining query criteria.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">A query name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Query</span>: <span class="description">A query.</span></div></div></section></div></div></div><div id="template-module" class="module"><h2>template</h2><div class="module-content"><h2>Methods:</h2><div id="template-module-methods"><section id="method-template-template" class="method"><h3>template.template(name, node) <span class="type">Function</span></h3><div class="description"><p>Client-side reactive templates (just plain DOM node manipulation, no strings).</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">The template's name.</div></li><li><span class="param-name">node</span> <span class="type">HTMLNode</span><div class="param-description">The HTML node.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Function</span>: <span class="description">The compiled template function.</span></div></div></section></div></div></div><div id="validator-module" class="module"><h2>validator</h2><div class="module-content"><h2>Methods:</h2><div id="validator-module-methods"><section id="method-validator-validator" class="method"><h3>validator.validator(name, fn) <span class="type">Function</span></h3><div class="description"><p>Get or set a validator function.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">Validator name.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Validator function.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Function</span>: <span class="description">Validator function.</span></div></div></section></div></div></div><div id="content-module" class="module"><h2>content</h2><div class="module-content"><div id="content-module-classes"><section id="class-content-Content" class="klass"><h3>Content Class:</h3><div class="description"><p>Class representing a specific data segment in the DOM.</p></div><div class="class-constructor"><h4>Constructor: Content(data)</h4><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">data</span> <span class="type">Object</span><div class="param-description">The content's data.</div></li></ul></div></div></section></div><h2>Methods:</h2><div id="content-module-methods"><section id="method-content-content" class="method"><h3>content.content(name, fn) <span class="type">Content</span></h3><div class="description"><p>Public API. Gets an existing content or creates a new one.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">The content's name.</div></li><li><span class="param-name">fn</span> <span class="type">Function</span><div class="param-description">Function called on content initialization.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Content</span>: <span class="description">A `Content` object.</span></div></div></section></div></div></div><div id="element-module" class="module"><h2>element</h2><div class="module-content"><h2>Methods:</h2><div id="element-module-methods"><section id="method-element-element" class="method"><h3>element.element(name) <span class="type">Function</span></h3><div class="description"><p>Get an<code>Element</code>.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">The element name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Function</span>: <span class="description">The Element class constructor.</span></div></div></section></div></div></div><div id="resource-module" class="module"><h2>resource</h2><div class="module-content"><div id="resource-module-classes"><section id="class-resource-Resource" class="klass"><h3>Resource Class:</h3><div class="description"><p>Initialize a new resource with the given<code>attrs</code>.</p></div><div class="class-constructor"><h4>Constructor: Resource(attrs, storedAttrs)</h4><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">attrs</span> <span class="type">Object</span><div class="param-description">An object with attributes.</div></li><li><span class="param-name">storedAttrs</span> <span class="type">Boolean</span><div class="param-description">Attributes that should not be dirtied.</div></li></ul></div></div></section></div><h2>Methods:</h2><div id="resource-module-methods"><section id="method-resource-resource" class="method"><h3>resource.resource(name) <span class="type">Function</span></h3><div class="description"><p>Create a new resource constructor with the given<code>name</code>.</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">name</span> <span class="type">String</span><div class="param-description">Resource name.</div></li></ul></div><div class="returns"><h4>Returns:</h4><div class="returns-description"><span class="type">Function</span>: <span class="description">The `Resource` class constructor.</span></div></div></section></div></div></div><div id="text-module" class="module"><h2>text</h2><div class="module-content"><h2>Methods:</h2><div id="text-module-methods"><section id="method-text-text" class="method"><h3>text.text(key)</h3><div class="description"><p>Example:</p><p>text('messages')</p></div><div class="params"><h4>Parameters:</h4><ul class="params-list"><li><span class="param-name">key</span> <span class="type">String</span><div class="param-description"></div></li></ul></div></section></div></div></div></div></div><div class="span3"><nav class="sidebar-nav-fixed"><ul class="nav nav-list"><li class="module"><h4><a href="#adapter-module" class="mod-link">adapter</a></h4><ul class="module-items"><li class="nav classes"><h5>Classes:</h5><ul id="adapter-Adapter-class" class="module-class"><li><a href="#class-adapter-Adapter" class="klass">Adapter</a><h6 class="class-indent">Adapter Methods:</h6><ul><li class="class-indent"><a href="#class-method-adapter-Adapter-query" class="klass-method">query</a></li><li class="class-indent"><a href="#class-method-adapter-Adapter-use" class="klass-method">use</a></li><li class="class-indent"><a href="#class-method-adapter-Adapter-connection" class="klass-method">connection</a></li><li class="class-indent"><a href="#class-method-adapter-Adapter-type" class="klass-method">type</a></li><li class="class-indent"><a href="#class-method-adapter-Adapter-serializer" class="klass-method">serializer</a></li><li class="class-indent"><a href="#class-method-adapter-Adapter-to" class="klass-method">to</a></li><li class="class-indent"><a href="#class-method-adapter-Adapter-from" class="klass-method">from</a></li><li class="class-indent"><a href="#class-method-adapter-Adapter-exec" class="klass-method">exec</a></li><li class="class-indent"><a href="#class-method-adapter-Adapter-self" class="klass-method">self</a></li></ul></li></ul></li><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-adapter-adapter">adapter</a></li></ul></li></ul></li><li class="module"><h4><a href="#cookbook-module" class="mod-link">cookbook</a></h4><ul class="module-items"></ul></li><li class="module"><h4><a href="#expression-module" class="mod-link">expression</a></h4><ul class="module-items"><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-expression-expression">expression</a></li></ul></li></ul></li><li class="module"><h4><a href="#route-module" class="mod-link">route</a></h4><ul class="module-items"><li class="nav classes"><h5>Classes:</h5><ul id="route-Route-class" class="module-class"><li><a href="#class-route-Route" class="klass">Route</a><h6 class="class-indent">Route Methods:</h6><ul><li class="class-indent"><a href="#class-method-route-Route-param" class="klass-method">param</a></li><li class="class-indent"><a href="#class-method-route-Route-type" class="klass-method">type</a></li><li class="class-indent"><a href="#class-method-route-Route-use" class="klass-method">use</a></li><li class="class-indent"><a href="#class-method-route-Route-accept" class="klass-method">accept</a></li><li class="class-indent"><a href="#class-method-route-Route-format" class="klass-method">format</a></li><li class="class-indent"><a href="#class-method-route-Route-action" class="klass-method">action</a></li><li class="class-indent"><a href="#class-method-route-Route-self" class="klass-method">self</a></li><li class="class-indent"><a href="#class-method-route-Route-handle" class="klass-method">handle</a></li><li class="class-indent"><a href="#class-method-route-Route-parseParams" class="klass-method">parseParams</a></li></ul></li></ul></li><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-route-route">route</a></li></ul></li></ul></li><li class="module"><h4><a href="#type-module" class="mod-link">type</a></h4><ul class="module-items"><li class="nav classes"><h5>Classes:</h5><ul id="type-Type-class" class="module-class"><li><a href="#class-type-Type" class="klass">Type</a><h6 class="class-indent">Type Methods:</h6><ul><li class="class-indent"><a href="#class-method-type-Type-validator" class="klass-method">validator</a></li><li class="class-indent"><a href="#class-method-type-Type-use" class="klass-method">use</a></li><li class="class-indent"><a href="#class-method-type-Type-sanitize" class="klass-method">sanitize</a></li><li class="class-indent"><a href="#class-method-type-Type-serializer" class="klass-method">serializer</a></li><li class="class-indent"><a href="#class-method-type-Type-to" class="klass-method">to</a></li><li class="class-indent"><a href="#class-method-type-Type-from" class="klass-method">from</a></li></ul></li></ul></li><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-type-type">type</a></li></ul></li></ul></li><li class="module"><h4><a href="#cli-module" class="mod-link">cli</a></h4><ul class="module-items"></ul></li><li class="module"><h4><a href="#directive-module" class="mod-link">directive</a></h4><ul class="module-items"><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-directive-directive">directive</a></li></ul></li></ul></li><li class="module"><h4><a href="#query-module" class="mod-link">query</a></h4><ul class="module-items"><li class="nav classes"><h5>Classes:</h5><ul id="query-Query-class" class="module-class"><li><a href="#class-query-Query" class="klass">Query</a><h6 class="class-indent">Query Methods:</h6><ul><li class="class-indent"><a href="#class-method-query-Query-use" class="klass-method">use</a></li><li class="class-indent"><a href="#class-method-query-Query-start" class="klass-method">start</a></li><li class="class-indent"><a href="#class-method-query-Query-select" class="klass-method">select</a></li><li class="class-indent"><a href="#class-method-query-Query-where" class="klass-method">where</a></li><li class="class-indent"><a href="#class-method-query-Query-incoming" class="klass-method">incoming</a></li><li class="class-indent"><a href="#class-method-query-Query-outgoing" class="klass-method">outgoing</a></li><li class="class-indent"><a href="#class-method-query-Query-as" class="klass-method">as</a></li><li class="class-indent"><a href="#class-method-query-Query-contains" class="klass-method">contains</a></li><li class="class-indent"><a href="#class-method-query-Query-create" class="klass-method">create</a></li><li class="class-indent"><a href="#class-method-query-Query-update" class="klass-method">update</a></li><li class="class-indent"><a href="#class-method-query-Query-first" class="klass-method">first</a></li><li class="class-indent"><a href="#class-method-query-Query-last" class="klass-method">last</a></li><li class="class-indent"><a href="#class-method-query-Query-limit" class="klass-method">limit</a></li><li class="class-indent"><a href="#class-method-query-Query-page" class="klass-method">page</a></li><li class="class-indent"><a href="#class-method-query-Query-offset" class="klass-method">offset</a></li><li class="class-indent"><a href="#class-method-query-Query-asc" class="klass-method">asc</a></li><li class="class-indent"><a href="#class-method-query-Query-desc" class="klass-method">desc</a></li><li class="class-indent"><a href="#class-method-query-Query-explain" class="klass-method">explain</a></li><li class="class-indent"><a href="#class-method-query-Query-clone" class="klass-method">clone</a></li><li class="class-indent"><a href="#class-method-query-Query-exec" class="klass-method">exec</a></li><li class="class-indent"><a href="#class-method-query-Query-validate" class="klass-method">validate</a></li><li class="class-indent"><a href="#class-method-query-Query-subscribe" class="klass-method">subscribe</a></li><li class="class-indent"><a href="#class-method-query-Query-query" class="klass-method">query</a></li></ul></li></ul><ul id="query-Constraint-class" class="module-class"><li><a href="#class-query-Constraint" class="klass">Constraint</a></li></ul></li><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-query-query">query</a></li></ul></li></ul></li><li class="module"><h4><a href="#template-module" class="mod-link">template</a></h4><ul class="module-items"><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-template-template">template</a></li></ul></li></ul></li><li class="module"><h4><a href="#validator-module" class="mod-link">validator</a></h4><ul class="module-items"><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-validator-validator">validator</a></li></ul></li></ul></li><li class="module"><h4><a href="#content-module" class="mod-link">content</a></h4><ul class="module-items"><li class="nav classes"><h5>Classes:</h5><ul id="content-Content-class" class="module-class"><li><a href="#class-content-Content" class="klass">Content</a></li></ul></li><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-content-content">content</a></li></ul></li></ul></li><li class="module"><h4><a href="#element-module" class="mod-link">element</a></h4><ul class="module-items"><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-element-element">element</a></li></ul></li></ul></li><li class="module"><h4><a href="#resource-module" class="mod-link">resource</a></h4><ul class="module-items"><li class="nav classes"><h5>Classes:</h5><ul id="resource-Resource-class" class="module-class"><li><a href="#class-resource-Resource" class="klass">Resource</a></li></ul></li><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-resource-resource">resource</a></li></ul></li></ul></li><li class="module"><h4><a href="#text-module" class="mod-link">text</a></h4><ul class="module-items"><li class="nav methods"><h5>Methods:</h5><ul><li><a href="#method-text-text">text</a></li></ul></li></ul></li></ul></nav></div></div></div></section><footer></footer></div></body>