1 | import richText from 'rich-text'
|
2 | import Racer from 'racer'
|
3 | import Query from 'racer/lib/Model/Query'
|
4 | import { promisifyAll } from 'bluebird'
|
5 | import batch from './batch'
|
6 | import ormPlugin from '@startupjs/orm'
|
7 |
|
8 | export default (ShareDB, { orm } = {}) => {
|
9 | // Register rich-text type in ShareDB
|
10 | ShareDB.types.register(richText.type)
|
11 |
|
12 | // Promisify the default model methods like subscribe, fetch, set, push, etc.
|
13 | promisifyAll(Racer.Model.prototype)
|
14 | promisifyAll(Query.prototype)
|
15 |
|
16 | // Add batching method
|
17 | Racer.Model.prototype.batch = batch
|
18 |
|
19 | if (orm) {
|
20 | Racer.use(ormPlugin)
|
21 | Racer.use(orm)
|
22 | }
|
23 | }
|