Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localStorage data provider #5329

Merged
merged 1 commit into from
Oct 1, 2020
Merged

Add localStorage data provider #5329

merged 1 commit into from
Oct 1, 2020

Conversation

fzaninotto
Copy link
Member

An admin can use localStorage for part of or all the underlying data. A localStorage dataProvider opens the possibility to build local-first admins.

import localStorageDataProvider from 'ra-data-local-storage';
const dataProvider = localStorageDataProvider();

Uses ra-data-fakerest under the hood, synchronizing changes between the FakeRest (in-memory) and localStorage databases. It also hides warnings for undefined collections, and allows the addition of a record to an undefined collection.

Note that localStorage is limited to 5MB in size.

@fzaninotto fzaninotto added the RFR Ready For Review label Sep 30, 2020
@djhi
Copy link
Collaborator

djhi commented Oct 1, 2020

I don't really get why it needs fakerest. Can you elaborate ?

@fzaninotto
Copy link
Member Author

To avoid duplicating the code needed to handle dataProvider requests in an in memory database. Basically this entire file:

https://github.com/marmelab/FakeRest/blob/master/src/Collection.js

@djhi djhi added this to the 3.9.0 milestone Oct 1, 2020
@djhi djhi merged commit cb794b5 into master Oct 1, 2020
@djhi djhi deleted the ra-data-localstorage branch October 1, 2020 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants