Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/charliehess/redux-persist-sqlite
A redux-persist storage adapter that writes to sqlite
https://github.com/charliehess/redux-persist-sqlite
redux redux-persist sqlite
Last synced: 3 months ago
JSON representation
A redux-persist storage adapter that writes to sqlite
- Host: GitHub
- URL: https://github.com/charliehess/redux-persist-sqlite
- Owner: CharlieHess
- Created: 2019-03-04T02:44:38.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T02:06:59.000Z (almost 6 years ago)
- Last Synced: 2024-09-21T23:51:57.488Z (4 months ago)
- Topics: redux, redux-persist, sqlite
- Language: TypeScript
- Size: 27.3 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# redux-persist-sqlite
A redux-persist storage adapter that writes to [sqlite](https://github.com/mapbox/node-sqlite3).
This is adapted from https://github.com/prsn/redux-persist-sqlite-storage, but uses Node.js sqlite3 rather than react-native.
Great for Electron apps that are backed by Redux.
## install
```
npm i redux-persist-sqlite
```## usage
``` typescript
// configureStore.ts
import { createStore } from 'redux';
import { persistStore, persistReducer } from 'redux-persist';
import { SQLiteAdapter } from 'redux-persist-sqlite';const yourDbName = 'redux-persist.db';
const pathToYourDB = path.join(process.cwd(), yourDbName);const rootPersistConfig = {
key: 'root',
storage: new SQLiteAdapter(pathToYourDB)
};const persistedReducer = persistReducer(persistConfig, rootReducer);
export function configureStore() {
const store = createStore(persistedReducer);
const persistor = persistStore(store);
return { store, persistor };
}
```