https://github.com/tableflip/ssb-mongo-connect
Connect ssb messages to mongo collections.
https://github.com/tableflip/ssb-mongo-connect
Last synced: 8 months ago
JSON representation
Connect ssb messages to mongo collections.
- Host: GitHub
- URL: https://github.com/tableflip/ssb-mongo-connect
- Owner: tableflip
- License: agpl-3.0
- Created: 2017-06-12T10:05:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-12T11:12:57.000Z (about 9 years ago)
- Last Synced: 2025-08-27T00:26:35.413Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 79.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ssb-mongo-connect [](https://travis-ci.org/tableflip/ssb-mongo-connect) [](https://david-dm.org/tableflip/ssb-mongo-connect)
Connect ssb messages to mongo collections.
```js
var sbot = require('scuttlebot')({ /* ... */ })
var connect = require('ssb-mongo-connect')
var db = require('mongojs')('blog', ['posts'])
var Posts = db.collection('posts')
var conn = connect(sbot, 'add-post')(Posts)
// All future add-post messages will now appear in the Posts collection
// (Call `conn.abort()` to stop)
```
## API
### `connect(sbot, messageType[, opts])(collection)`
Connect scuttlebot messages of type `messageType` to the mongo `collection`.
* `sbot` (`Scuttlebot`) a scuttlebot server
* `messageType` (`String`|`Array`) the type(s) of message to connect to this collection
* `[opts.transform]` (`Function`) async transform the message contents before inserting into mongo (signature is `transform (content, cb)`). Callback with `null` to effectively filter messages
* `[opts.gte]` (`Number`) optional timestamp after which to start receiving messages (default `Date.now()`)
* `[opts.concurrency]` (`Number`) the number of concurrent mongo inserts (default 1 to maintain message order)
* `collection` (`Object`) a mongo collection object
Returns a [`pull-abortable`](https://pull-stream.github.io/#pull-abortable) instance, allowing you to call `abort([err])` in order to stop the connection.
----
A [(╯°□°)╯︵TABLEFLIP](https://tableflip.io) side project.