Added docs
This commit is contained in:
parent
b7325a110e
commit
be9a144f47
|
@ -0,0 +1,2 @@
|
|||
jugglingdb-adapter(3) - Adapter API explained.
|
||||
====================
|
|
@ -0,0 +1,2 @@
|
|||
jugglingdb-hooks(3) - Hooks and object lifecycle.
|
||||
==================
|
|
@ -41,6 +41,12 @@
|
|||
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
|
||||
ol.man-decor li.tr {text-align:right;float:right}
|
||||
</style>
|
||||
<style type='text/css' media='print'>
|
||||
/* style: print */
|
||||
.mp {max-width:none}
|
||||
.man-navigation {display:none !important}
|
||||
.mp a[href]:not([href^="#"]):not([data-bare-link]):after {content:" " attr(href)}
|
||||
</style>
|
||||
<style type='text/css' media='all'>
|
||||
/* style: toc */
|
||||
.man-navigation {display:block !important;position:fixed;top:0;left:113ex;height:100%;width:100%;padding:48px 0 0 0;border-left:1px solid #dbdbdb;background:#eee}
|
||||
|
@ -68,7 +74,7 @@
|
|||
<a href="#FUTURE">FUTURE</a>
|
||||
<a href="#BUGS">BUGS</a>
|
||||
<a href="#HISTORY">HISTORY</a>
|
||||
<a href="#LICENSE">LICENSE</a>
|
||||
<a href="#COPYRIGHT">COPYRIGHT</a>
|
||||
<a href="#AUTHOR">AUTHOR</a>
|
||||
<a href="#CONTRIBUTORS">CONTRIBUTORS</a>
|
||||
<a href="#SEE-ALSO">SEE ALSO</a>
|
||||
|
@ -115,7 +121,8 @@ which allows to write rich client-side apps talking to server using JSON API.</p
|
|||
|
||||
<h2 id="DOCUMENTATION">DOCUMENTATION</h2>
|
||||
|
||||
<p>Autogenerated documentation available at <a href="https://jsdoc.info/1602/jugglingdb">jsdoc.info/1602/jugglingdb</a>. Human-written manual sections are:</p>
|
||||
<p>Autogenerated documentation available at <a href="http://jsdoc.info/1602/jugglingdb">jsdoc.info/1602/jugglingdb</a>.
|
||||
Human-written manual sections are:</p>
|
||||
|
||||
<dl>
|
||||
<dt><a class="man-ref" href="schema.3.html">jugglingdb-schema<span class="s">(3)</span></a></dt><dd><p>Everything about schema, data types and model definition.</p></dd>
|
||||
|
@ -123,16 +130,33 @@ which allows to write rich client-side apps talking to server using JSON API.</p
|
|||
<dt><a class="man-ref" href="validations.3.html">jugglingdb-validations<span class="s">(3)</span></a></dt><dd><p>Built-in validators, creating custom validations, syncronous and asyncronous
|
||||
object validation.</p></dd>
|
||||
<dt><a class="man-ref" href="hooks.3.html">jugglingdb-hooks<span class="s">(3)</span></a></dt><dd><p>Hooks and object lifecycle.</p></dd>
|
||||
<dt><span class="man-ref">jugglingdb-adapter<span class="s">(3)</span></span></dt><dd><p>Adapter API explained.</p></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<h2 id="ADAPTERS">ADAPTERS</h2>
|
||||
|
||||
<p>All adapters available as separate packages at
|
||||
<a href="https://github.com/jugglingdb">github.com/jugglingdb</a> and published in npm.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="https://github.com/jugglingdb/mysql-adapter">jugglingdb-mysql</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/sqlite3-adapter">jugglingdb-sqlite3</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/postgres-adapter">jugglingdb-postgres</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/redis-adapter">jugglingdb-redis</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/mongodb-adapter">jugglingdb-mongodb</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/nano-adapter">jugglingdb-nano</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/firebird-adapter">jugglingdb-firebird</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2 id="CONTRIBUTION">CONTRIBUTION</h2>
|
||||
|
||||
<p>TODO: briefly describe contribution</p>
|
||||
|
||||
<h2 id="FUTURE">FUTURE</h2>
|
||||
|
||||
<p>See <a class="man-ref" href="roadmap.3.html">jugglingdb-roadmap<span class="s">(3)</span></a> and [github issues][issues] to catch up current
|
||||
<p>See <a class="man-ref" href="roadmap.3.html">jugglingdb-roadmap<span class="s">(3)</span></a> and <a href="https://github.com/1602/jugglingdb/issues?state=open">github issues</a> to catch up current
|
||||
development and see how you can help jugglingdb to grow up.</p>
|
||||
|
||||
<h2 id="BUGS">BUGS</h2>
|
||||
|
@ -142,17 +166,20 @@ development and see how you can help jugglingdb to grow up.</p>
|
|||
<dl>
|
||||
<dt>github/core</dt><dd><a href="https://github.com/1602/jugglingdb/issues" data-bare-link="true">https://github.com/1602/jugglingdb/issues</a></dd>
|
||||
<dt>github/adapters</dt><dd><a href="https://github.com/jugglingdb" data-bare-link="true">https://github.com/jugglingdb</a></dd>
|
||||
<dt class="flush">email</dt><dd><a href="mailto:compoundjs@googlegroups.com" data-bare-link="true">compoundjs@googlegroups.com</a></dd>
|
||||
<dt class="flush">email</dt><dd><a href="mailto:compoundjs@googlegroups.com" data-bare-link="true">compoundjs@googlegroups.com</a></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<p>Provide test case for reproducing error. When reporting issue to core mention
|
||||
adapter where problem could be reproduced.</p>
|
||||
|
||||
<h2 id="HISTORY">HISTORY</h2>
|
||||
|
||||
<p>See <a class="man-ref" href="changelog.3.html">jugglingdb-changelog<span class="s">(3)</span></a></p>
|
||||
|
||||
<h2 id="LICENSE">LICENSE</h2>
|
||||
<h2 id="COPYRIGHT">COPYRIGHT</h2>
|
||||
|
||||
<p>JugglingDB has MIT license, see <span class="man-ref">jugglingdb-license<span class="s">(3)</span></span> for details.</p>
|
||||
<p>JugglingDB is Copyright (C) 2011 Anatoliy Chakkaev http://anatoliy.in</p>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
|
@ -161,7 +188,7 @@ development and see how you can help jugglingdb to grow up.</p>
|
|||
<li><a href="https://github.com/1602/">github/1602</a></li>
|
||||
<li><a href="https://github.com/anatoliychakkaev/">github/anatoliychakkaev</a></li>
|
||||
<li><a href="http://twitter.com/1602">twitter@1602</a></li>
|
||||
<li><a href="mailto:mail@anatoliy.in" data-bare-link="true">mail@anatoliy.in</a></li>
|
||||
<li><a href="mailto:mail@anatoliy.in" data-bare-link="true">mail@anatoliy.in</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -170,7 +197,7 @@ development and see how you can help jugglingdb to grow up.</p>
|
|||
<h3 id="core-contributors-more-than-1-">core contributors (more than 1%)</h3>
|
||||
|
||||
<pre><code>410 Anatoliy Chakkaev 73.9%
|
||||
31 Sébastien Drouyer 5.6%
|
||||
31 Sebastien Drouyer 5.6%
|
||||
25 1602 4.5%
|
||||
9 Muneeb Samuels 1.6%
|
||||
6 Henri Bergius 1.1%
|
||||
|
@ -179,10 +206,15 @@ development and see how you can help jugglingdb to grow up.</p>
|
|||
<h3 id="adapters-maintainers">adapters maintainers</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="https://github.com/jugglingdb/nano-adapter">jugglingdb-nano</a> -- <a href="https://github.com/nrw">Nicholas Westlake</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/nano-adapter">jugglingdb-nano</a> - <a href="https://github.com/nrw">Nicholas Westlake</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/mysql-adapter">jugglingdb-mysql</a> - <a href="https://github.com/dgsan">dgsan</a></li>
|
||||
<li><a href="https://github.com/jugglingdb/firebird-adapter">jugglingdb-firebird</a> - <a href="https://github.com/hgourvest">Henri Gourvest</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p><em>NOTE:</em> Other adapters waits for their maintainers, drop a line to
|
||||
mail@anatoliy.in if you want to maintain some adapter on regular basis.</p>
|
||||
|
||||
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# man pages
|
||||
jugglingdb(3) index
|
||||
jugglingdb-changelog(3) changelog.3
|
||||
jugglingdb-roadmap(3) roadmap.3
|
||||
|
@ -5,5 +6,19 @@ jugglingdb-validations(3) validations.3
|
|||
jugglingdb-hooks(3) hooks.3
|
||||
jugglingdb-schema(3) schema.3
|
||||
jugglingdb-model(3) model.3
|
||||
jugglingdb-adapter(3) adapter.3
|
||||
|
||||
# adapters
|
||||
jugglingdb-nano https://github.com/jugglingdb/nano-adapter
|
||||
jugglingdb-mysql https://github.com/jugglingdb/mysql-adapter
|
||||
jugglingdb-firebird https://github.com/jugglingdb/firebird-adapter
|
||||
jugglingdb-sqlite3 https://github.com/jugglingdb/sqlite3-adapter
|
||||
jugglingdb-postgres https://github.com/jugglingdb/postgres-adapter
|
||||
jugglingdb-redis https://github.com/jugglingdb/redis-adapter
|
||||
jugglingdb-mongodb https://github.com/jugglingdb/mongodb-adapter
|
||||
|
||||
# external resources
|
||||
github.com/jugglingdb https://github.com/jugglingdb
|
||||
github.com/1602/jugglingdb https://github.com/1602/jugglingdb
|
||||
issues https://github.com/1602/jugglingdb/issues?state=open
|
||||
jsdoc.info/1602/jugglingdb http://jsdoc.info/1602/jugglingdb
|
||||
|
|
|
@ -29,7 +29,8 @@ See jugglingdb-adapters(3) for list of available adapters.
|
|||
|
||||
## DOCUMENTATION
|
||||
|
||||
Autogenerated documentation available at [jsdoc.info/1602/jugglingdb](https://jsdoc.info/1602/jugglingdb). Human-written manual sections are:
|
||||
Autogenerated documentation available at [jsdoc.info/1602/jugglingdb].
|
||||
Human-written manual sections are:
|
||||
|
||||
* jugglingdb-schema(3):
|
||||
Everything about schema, data types and model definition.
|
||||
|
@ -44,10 +45,26 @@ Autogenerated documentation available at [jsdoc.info/1602/jugglingdb](https://js
|
|||
* jugglingdb-hooks(3):
|
||||
Hooks and object lifecycle.
|
||||
|
||||
* jugglingdb-adapter(3):
|
||||
Adapter API explained.
|
||||
|
||||
## ADAPTERS
|
||||
|
||||
All adapters available as separate packages at
|
||||
[github.com/jugglingdb] and published in npm.
|
||||
|
||||
* [jugglingdb-mysql]
|
||||
* [jugglingdb-sqlite3]
|
||||
* [jugglingdb-postgres]
|
||||
* [jugglingdb-redis]
|
||||
* [jugglingdb-mongodb]
|
||||
* [jugglingdb-nano]
|
||||
* [jugglingdb-firebird]
|
||||
|
||||
## CONTRIBUTION
|
||||
|
||||
TODO: briefly describe contribution
|
||||
|
||||
## FUTURE
|
||||
|
||||
See jugglingdb-roadmap(3) and [github issues][issues] to catch up current
|
||||
|
@ -64,13 +81,16 @@ When you find issues, please report them:
|
|||
* email:
|
||||
<compoundjs@googlegroups.com>
|
||||
|
||||
Provide test case for reproducing error. When reporting issue to core mention
|
||||
adapter where problem could be reproduced.
|
||||
|
||||
## HISTORY
|
||||
|
||||
See jugglingdb-changelog(3)
|
||||
|
||||
## LICENSE
|
||||
## COPYRIGHT
|
||||
|
||||
JugglingDB has MIT license, see jugglingdb-license(3) for details.
|
||||
JugglingDB is Copyright (C) 2011 Anatoliy Chakkaev http://anatoliy.in
|
||||
|
||||
## AUTHOR
|
||||
|
||||
|
@ -84,7 +104,7 @@ JugglingDB has MIT license, see jugglingdb-license(3) for details.
|
|||
|
||||
### core contributors (more than 1%)
|
||||
410 Anatoliy Chakkaev 73.9%
|
||||
31 Sébastien Drouyer 5.6%
|
||||
31 Sebastien Drouyer 5.6%
|
||||
25 1602 4.5%
|
||||
9 Muneeb Samuels 1.6%
|
||||
6 Henri Bergius 1.1%
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
jugglingdb-model(3) - Model methods, features and internals
|
||||
===================
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
This section describes common methods of models managed by jugglingdb and
|
||||
explains some model internals, such as data representation, setters, getters and
|
||||
virtual attributes.
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
jugglingdb-schema(3)
|
||||
jugglingdb-validations(3)
|
||||
jugglingdb-hooks(3)
|
||||
jugglingdb-adapter(3)
|
|
@ -0,0 +1,126 @@
|
|||
jugglingdb-schema(3) - Everything about schema, data types and model definition.
|
||||
====================
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Schema is a factory for classes. Schema connected with specific database using
|
||||
adapter.
|
||||
|
||||
All classes within single schema shares same adapter type and one database
|
||||
connection. But it's possible to use more than one schema to connect with
|
||||
different databases.
|
||||
|
||||
## EVENTS
|
||||
|
||||
Instances of Schema are event emitters, events supported by default:
|
||||
|
||||
* `.on('connected', function() {})`:
|
||||
Fired when db connection established. Params: none.
|
||||
* `.on('log', function(msg, duration) {})`:
|
||||
Fired when adapter logged line. Params: String message, Number duration
|
||||
|
||||
## USAGE
|
||||
|
||||
### Creating schema
|
||||
|
||||
`Schema` constructor available on `jugglingdb` module:
|
||||
|
||||
var Schema = require('jugglingdb').Schema;
|
||||
|
||||
Schema constructor accepts two arguments. First argument is adapter. It could be
|
||||
adapter name or adapter package:
|
||||
|
||||
var schemaByAdapterName = new Schema('memory');
|
||||
var schemaByAdapterPackage = new Schema(require('redis'));
|
||||
|
||||
### Settings
|
||||
|
||||
Second argument is optional settings. Settings object format and defaults
|
||||
depends on specific adapter, but common fields are:
|
||||
|
||||
* `host`:
|
||||
Database host
|
||||
* `port`:
|
||||
Database port
|
||||
* `username`:
|
||||
Username to connect to database
|
||||
* `password`:
|
||||
Password to connect to database
|
||||
* `database`:
|
||||
Database name
|
||||
* `debug`:
|
||||
Turn on verbose mode to debug db queries and lifecycle
|
||||
|
||||
For adapter-specific settings refer to adapter's readme file.
|
||||
|
||||
### Connecting to database
|
||||
|
||||
Schema connecting to database automatically. Once connection established schema
|
||||
object emit 'connected' event, and set `connected` flag to true, but it is not
|
||||
necessary to wait for 'connected' event because all queries cached and executed
|
||||
when schema emit 'connected' event.
|
||||
|
||||
To disconnect from database server call `schema.disconnect` method. This call
|
||||
forwarded to adapter if adapter have ability to connect/disconnect.
|
||||
|
||||
### Model definition
|
||||
|
||||
To define model schema have single method `schema.define`. It accepts three
|
||||
argumets:
|
||||
|
||||
* **model name**:
|
||||
String name in camel-case with first upper-case letter. This name will be used
|
||||
later to access model.
|
||||
* **properties**:
|
||||
Object with property type definitions. Key is property name, value is type
|
||||
definition. Type definition can be function representing type of property
|
||||
(String, Number, Date, Boolean), or object with {type: String|Number|...,
|
||||
index: true|false} format.
|
||||
* **settings**:
|
||||
Object with model-wide settings such as `tableName` or so.
|
||||
|
||||
Examples of model definition:
|
||||
|
||||
var User = schema.define('User', {
|
||||
email: String,
|
||||
password: String,
|
||||
birthDate: Date,
|
||||
activated: Boolean
|
||||
});
|
||||
|
||||
var User = schema.define('User', {
|
||||
email: { type: String, limit: 150, index: true },
|
||||
password: { type: String, limit: 50 },
|
||||
birthDate: Date,
|
||||
registrationDate: {
|
||||
type: Date,
|
||||
default: function () { return new Date }
|
||||
},
|
||||
activated: { type: Boolean, default: false }
|
||||
}, {
|
||||
tableName: 'users'
|
||||
});
|
||||
|
||||
### DB structure syncronization
|
||||
|
||||
Schema instance have two methods for updating db structure: automigrate and
|
||||
autoupdate.
|
||||
|
||||
The `automigrate` method drop table (if exists) and create it again,
|
||||
`autoupdate` method generates ALTER TABLE query. Both method accepts callback
|
||||
called when migration/update done.
|
||||
|
||||
To check if any db changes required use `isActual` method. It accepts single
|
||||
`callback` argument, which receive boolean value depending on db state: false if
|
||||
db structure outdated, true when schema and db is in sync:
|
||||
|
||||
schema.isActual(function(err, actual) {
|
||||
if (!actual) {
|
||||
schema.autoupdate();
|
||||
}
|
||||
});
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
jugglingdb-model(3)
|
||||
jugglingdb-adapter(3)
|
|
@ -0,0 +1,2 @@
|
|||
jugglingdb-validations(3) - Built-in validators, creating custom validations, syncronous and asyncronous object validation.
|
||||
========================
|
|
@ -20,7 +20,7 @@ case $dest in
|
|||
|
||||
*.html)
|
||||
ronn -5 $1 --pipe\
|
||||
--style=toc\
|
||||
--style='print toc'\
|
||||
--organization=1602\ Software\
|
||||
--manual=JugglingDB > $2
|
||||
exit $?
|
||||
|
|
Loading…
Reference in New Issue