Built on top of the codebase from redux-persist-electron-storage
Storage adapter to use nedb with redux-persist
npm i -S nedb redux-persist-nedb-storage deep-parse-json
yarn add nedb redux-persist-nedb-storage deep-parse-json
To use redux-persist-nedb-storage, configure redux-persist according to its documentation.
Modify the classic redux-persist configuration as follows, including the deep-parse-json package:
- Do not import
redux-persist/lib/storage
anymore, as we use an alternative storage. - Import
redux-persist-nedb-storage
:
import createNeDBStorage from 'redux-persist-nedb-storage'
import deepParseJson from 'deep-parse-json'
- Modify the options for
persistReducer
in order to use the NeDB storage and set the deserialize option todeepParseJson
:
const persistConfig = {
key: 'root',
storage: createNeDBStorage(),
deserialize: deepParseJson
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
You can pass options like below:
createNeDBStorage({
databasePathname: 'mydb.db',
inMemoryOnly: false
})