rxdb-flexsearch
v0.1.1
Published
RxDB Plugin based on FlexSearch implementation
Downloads
251
Maintainers
Readme
RxDB - FlexSearch plugin
Install
npm i rxdb-flexsearch [email protected] --save
Usage
import { addRxPlugin } from 'rxdb';
import { getRxStorageMemory } from 'rxdb/plugins/storage-memory';
import { RxDBFlexSearchPlugin } from 'rxdb-flexsearch';
import { userSchema } from './schemas';
addRxPlugin(RxDBFlexSearchPlugin);
const database = await createRxDatabase({
storage: getRxStorageMemory(),
});
await database.addCollections({
users: {
schema: userSchema,
options: {
searchable: true,
},
},
});
...
const results = await collection.search(query: string);
console.log(results);
Import/Export indexes
await database.exportIndexes((key, data) => {
localStorage.setItem(key, data);
});
await database.importIndexes({
[key]: localStorage.getItem(key);
});
You can use the autoIndexExport
database option to automatically export indexes when the collection is modified.
const database = await createRxDatabase({
storage: getRxStorageMemory(),
options: {
autoIndexExport: (key, value) => {
localStorage.setItem(key, value);
},
}
});