docs/rx-storage-mongodb.html
On this page
RxDB MongoDB RxStorage is an RxDB RxStorage that allows you to use MongoDB as the underlying storage engine for your RxDB database. With this you can take advantage of MongoDB's features and scalability while benefiting from RxDB's real-time data synchronization capabilities.
The storage is made to work with any plain MongoDB Server, MongoDB Replica Set, Sharded MongoDB Cluster or Atlas Cloud Database.
1
npm install mongodb --save
2
To use the storage, you simply import the getRxStorageMongoDB method and use that when creating the RxDatabase. The connection parameter contains the MongoDB connection string.
import {
createRxDatabase
} from 'rxdb';
import {
getRxStorageMongoDB
} from 'rxdb/plugins/storage-mongodb';
const myRxDatabase = await createRxDatabase({
name: 'exampledb',
storage: getRxStorageMongoDB({
/**
* MongoDB connection string
* @link https://www.mongodb.com/docs/manual/reference/connection-string/
*/
connection: 'mongodb://localhost:27017,localhost:27018,localhost:27019'
})
});