MongoDB Storage Adapter for boco-sourced.
npm install boco-sourced-mongodb
Before using the adapter, you'll want to modify the schema as follows:
db.revisions.ensureIndex({ resourceType: 1, resourceId: 1, resourceVersion: 1 }, { unique: true })
For the examples below, we'll need the adapter module:
MongoAdapter = require 'boco-sourced-mongodb'
We'll use the assert
module to demonstrate behavior:
assert = require 'assert'
Let's create a configuration object for our adapter:
config = {}
Use the MongoDB connection string format to specify a connection to the database.
config.connectionString = "mongodb://localhost/sourcedExamples"
Specify the MongoDB collection name for revisions.
config.revisionsCollectionName = "revisions"
To create an instance of the adapter, pass in the config
object to the module's configure
method:
adapter = MongoAdapter.configure config
The adapter can now be used by boco-sourced:
Sourced = require 'boco-sourced'
sourced = Sourced.createService storage: adapter