Skip to content

Commit 3a732cc

Browse files
committed
Upd readme
1 parent edaef1f commit 3a732cc

File tree

1 file changed

+56
-10
lines changed

1 file changed

+56
-10
lines changed

README.md

+56-10
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ var User = schema.define('User', {
147147
restPath: '/users' // tell WebService adapter which path use as API endpoint
148148
});
149149

150+
var Group = schema.define('Group', {name: String});
151+
150152
// define any custom method
151153
User.prototype.getNameAndAge = function () {
152154
return this.name + ', ' + this.age;
@@ -155,7 +157,11 @@ User.prototype.getNameAndAge = function () {
155157
// models also accessible in schema:
156158
schema.models.User;
157159
schema.models.Post;
160+
```
158161

162+
SEE [schema(3)](http://jugglingdb.co/schema.3.html) for details schema usage.
163+
164+
```javascript
159165
// setup relationships
160166
User.hasMany(Post, {as: 'posts', foreignKey: 'userId'});
161167
// creates instance methods:
@@ -169,6 +175,12 @@ Post.belongsTo(User, {as: 'author', foreignKey: 'userId'});
169175
// post.author() -- sync getter when called without params
170176
// post.author(user) -- setter when called with object
171177

178+
User.hasAndBelongsToMany('groups');
179+
// user.groups(callback) - get groups of user
180+
// user.groups.create(data, callback) - create new group and connect with user
181+
// user.groups.add(group, callback) - connect existing group with user
182+
// user.groups.remove(group, callback) - remove connection between group and user
183+
172184
schema.automigrate(); // required only for mysql NOTE: it will drop User and Post tables
173185

174186
// work with models:
@@ -208,6 +220,12 @@ User.count([conditions, ]cb)
208220
user.destroy(cb);
209221
// destroy all instances
210222
User.destroyAll(cb);
223+
```
224+
225+
SEE [model(3)](http://jugglingdb.co/model.3.html) for more information about
226+
jugglingdb Model API. Or `man jugglingdb-model` in terminal.
227+
228+
```javascript
211229

212230
// Setup validations
213231
User.validatesPresenceOf('name', 'email')
@@ -225,9 +243,12 @@ user.isValid(function (valid) {
225243

226244
```
227245

228-
## Callbacks
246+
SEE ALSO [jugglingdb-validations(3)](http://jugglingdb.co/validations.3.html) or
247+
`man jugglingdb-validations` in terminal. Validation tests: ./test/validations.test.js
248+
249+
## Hooks
229250

230-
The following callbacks supported:
251+
The following hooks supported:
231252

232253
- afterInitialize
233254
- beforeCreate
@@ -279,8 +300,9 @@ User.create(data, callback);
279300
// callback
280301
```
281302

282-
Read the tests for usage examples: ./test/common_test.js
283-
Validations: ./test/validations.test.js
303+
SEE [jugglingdb-hooks](http://jugglingdb.co/hooks.3.html) or type this command
304+
in your fav terminal: `man jugglingdb-hooks`. Also check tests for usage
305+
examples: ./test/hooks.test.js
284306

285307
## Your own database adapter
286308

@@ -290,7 +312,9 @@ To use custom adapter, pass it's package name as first argument to `Schema` cons
290312

291313
In that case your adapter should be named as 'jugglingdb-mycouch' npm package.
292314

293-
## Testing
315+
## Testing [outdated]
316+
317+
TODO: upd this section
294318

295319
Core of jugglingdb tests only basic features (database-agnostic) like
296320
validations, hooks and runs db-specific tests using memory storage. It also
@@ -325,8 +349,30 @@ correctly (host, port, username, password).
325349

326350
## Contributing
327351

328-
If you have found a bug please write unit test, and make sure all other tests still pass before pushing code to repo.
329-
330-
## License
331-
332-
MIT
352+
If you have found a bug please try to write unit test before reporting. Before
353+
submit pull request make sure all tests still passed. Check
354+
[roadmap](http://jugglingdb.co/roadmap.3.html), github issues if you want to
355+
help. Contribution to docs highly appreciated. Contents of man pages and
356+
http://jugglingdb.co generated from md files stored in this repo at ./docs repo
357+
358+
## MIT License
359+
360+
Copyright (C) 2011 by Anatoliy Chakkaev <mail [åt] anatoliy [døt] in>
361+
362+
Permission is hereby granted, free of charge, to any person obtaining a copy
363+
of this software and associated documentation files (the "Software"), to deal
364+
in the Software without restriction, including without limitation the rights
365+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
366+
copies of the Software, and to permit persons to whom the Software is
367+
furnished to do so, subject to the following conditions:
368+
369+
The above copyright notice and this permission notice shall be included in
370+
all copies or substantial portions of the Software.
371+
372+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
373+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
374+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
375+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
376+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
377+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
378+
THE SOFTWARE.

0 commit comments

Comments
 (0)