Skip to content

Commit 46e52cd

Browse files
author
pemrouz
committed
docs: update readme
1 parent 02e6c83 commit 46e52cd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22
[![Coverage Status](https://coveralls.io/repos/rijs/db/badge.svg?branch=master&service=github)](https://coveralls.io/github/rijs/db?branch=master)
33
[![Build Status](https://travis-ci.org/rijs/db.svg)](https://travis-ci.org/rijs/db)
44

5-
Allows connecting a Ripple node to other external services
5+
Allows connecting a node to external services. For example, when a resource changes, it could update a database, synchronise with other instances over AMQP, or pump to Redis.
66

77
```js
88
ripple = require('rijs')({ db: 'type://user:password@host:port/database' })
99
```
1010

1111
It destructures the connection string into an object, looks up the `type` in `ripple.adaptors`, then passes that function the connection string as an object, and stores the result under `ripple.connections`.
1212

13-
You must register any adaptors you wish to use separate to this module. An adaptor is a function that takes the connection string as an object, creates an active connection and returns and object of four crud functions: `{ push, update, remove, load }`. These hooks will be invoked when the corresponding event occurs.
13+
```js
14+
ripple.connections.push(
15+
ripple.adaptors[type]({ type, user, database, port, host, password })
16+
)
17+
```
18+
19+
You must register any adaptors you wish to use separate to this module. An adaptor is a constructor function that takes the connection string as an object, creates an active connection and returns an object of functions for each possible change type: `{ add, update, remove }`. These hooks will be invoked when the corresponding event occurs.
20+
21+
```js
22+
ripple.on('change', ({ key, value, type }) =>
23+
ripple.connections.map(con =>
24+
con[type](res, key, value)))
25+
```

0 commit comments

Comments
 (0)