Skip to content

Instantly share code, notes, and snippets.

@ANUPAMCHAUDHARY1117
Last active July 19, 2020 13:06
Show Gist options
  • Save ANUPAMCHAUDHARY1117/968b2dcfc4f4798937ee002f586924a5 to your computer and use it in GitHub Desktop.
Save ANUPAMCHAUDHARY1117/968b2dcfc4f4798937ee002f586924a5 to your computer and use it in GitHub Desktop.
import React, { useEffect } from 'react';
import IndexedDb from './indexedDb'
const Test = () => {
useEffect(() => {
const runIndexDb = async () => {
const indexedDb = new IndexedDb('test');
await indexedDb.createObjectStore(['books', 'students']);
await indexedDb.putValue('books', { name: 'A Game of Thrones' });
await indexedDb.putBulkValue('books', [{ name: 'A Song of Fire and Ice' }, { name: 'Harry Potter and the Chamber of Secrets' }]);
await indexedDb.getValue('books', 1);
await indexedDb.getAllValue('books');
await indexedDb.deleteValue('books', 1);
}
runIndexDb();
}, []);
return (<React.Fragment></React.Fragment>)
}
export default Test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment