RxError: RxError:
RxDatabase.create(): Adapter not added. Use RxDB.plugin(require('pouchdb-adapter-[adaptername]');
Given parameters: {
adapter:"asyncstorage"}
database.js
//我的代码
import RxDB from 'rxdb';
import schema from './ramsSchema';
RxDB.plugin(require('pouchdb-adapter-asyncstorage').default);
RxDB.plugin(require('pouchdb-adapter-http'));
const syncURL = 'couchDB url'
//this function initializes the RxDB if DB already exists else creates a new one and returns the db instance
export async function initializeDB(dbName,password) {
const db = await RxDB.create({
name: dbName.toLowerCase(),
adapter: 'asyncstorage',
password:'rams@1234',
multiInstance: false,
ignoreDuplicate: true,
});
const collection = await db.collection({
name:'rams',
schema,
});
collection.sync({
remote: syncURL + dbName.toLowerCase() + '/',
options: {
live: true,
retry: true,
},
});
return db;
}
我该怎么补救呢?
1条答案
按热度按时间kokeuurv1#
createDatabase函数在文档中是这样使用的。
顺便说一下,RXDB文档中不赞成使用PouchDB。
RxStorage PouchDB的用法如下。