![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
react-indexed-db
Advanced tools
react-indexed-db is a service that wraps IndexedDB database in an "easier to use" service. It exposes very simple promises API to enable the usage of IndexedDB without most of it plumbing.
```
npm install react-indexed-db
```
Import the the ReactIndexedDB
class as a dependency:
import { ReactIndexedDB } from 'react-indexed-db';
First instantiate the service as follows:
let db = new ReactIndexedDB('myDb', 1);
The first argument is the name of your database and the second is the database version. If you forget the version you the service will default to version 1.
Use the APIs that the ReactIndexedDB service exposes to use indexeddb. In the API the following functions:
Usage example:
db.openDatabase(1, evt => {
let objectStore = evt.currentTarget.result.createObjectStore('people', { keyPath: 'id', autoIncrement: true });
objectStore.createIndex('name', 'name', { unique: false });
objectStore.createIndex('email', 'email', { unique: true });
});
Usage example:
db.getByKey('people', 1).then(
person => {
console.log(person);
},
error => {
console.log(error);
}
);
Usage example:
db.getAll('people').then(
people => {
console.log(people);
},
error => {
console.log(error);
}
);
Usage example:
db.getByIndex('people', 'name', 'Dave').then(
person => {
console.log(person);
},
error => {
console.log(error);
}
);
Usage example (add without a key):
db.add('people', { name: 'name', email: 'email' }).then(
() => {
// Do something after the value was added
},
error => {
console.log(error);
}
);
In the previous example I'm using undefined as the key because the key is configured in the objectStore as auto-generated.
Usage example (update without a key):
db.update('people', { id: 3, name: 'name', email: 'email' }).then(
() => {
// Do something after update
},
error => {
console.log(error);
}
);
Usage example:
db.delete('people', 3).then(
() => {
// Do something after delete
},
error => {
console.log(error);
}
);
Usage example:
db.openCursor('people', (evt) => {
var cursor = (<any>evt.target).result;
if(cursor) {
console.log(cursor.value);
cursor.continue();
} else {
console.log('Entries all displayed.');
}
}, IDBKeyRange.bound("A", "F"));
Usage example:
db.clear('people').then(
() => {
// Do something after clear
},
error => {
console.log(error);
}
);
Released under the terms of the MIT License.
FAQs
React wrapper to IndexedDB database.
The npm package react-indexed-db receives a total of 715 weekly downloads. As such, react-indexed-db popularity was classified as not popular.
We found that react-indexed-db demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.