UNPKG

612 BJavaScriptView Raw
1import richText from 'rich-text'
2import Racer from 'racer'
3import Query from 'racer/lib/Model/Query'
4import { promisifyAll } from 'bluebird'
5import batch from './batch'
6import ormPlugin from '@startupjs/orm'
7
8export 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}