3.6.0 • Published 10 months ago
react-native-leveldb v3.6.0
react-native-leveldb
Sponsored by
Superfast React Native bindings for LevelDB:
- 2-7x faster than AsyncStorage or react-native-sqlite-storage - try the benchmarks under example/!
- completely synchronous, blocking API (even on slow devices, a single read or write takes 0.1ms)
- use it with Flatbuffers to turbo charge your app - support for binary data via ArrayBuffers
Installation
yarn add react-native-leveldb
cd ios && pod install
Usage
import {LevelDB} from "react-native-leveldb";
// Open a potentially new database.
const name = 'example.db';
const createIfMissing = true;
const errorIfExists = false;
const db = new LevelDB(name, createIfMissing, errorIfExists);
// Insert something into the database. Note that the key and the
// value can either be strings or ArrayBuffers.
// Strings are read & written in utf8.
db.put('key', 'value');
// You can also use ArrayBuffers as input, containing binary data.
const key = new Uint8Array([1, 2, 3]);
const value = new Uint32Array([654321]);
db.put(key.buffer, value.buffer);
// Get values as string or as an ArrayBuffer (useful for binary data).
const readStringValue = db.getStr('key');
const readBufferValue = new Uint32Array(db.getBuf(key.buffer)!);
console.log(readStringValue, readBufferValue); // logs: value [654321]
// Iterate over a range of values (here, from key "key" to the end.)
let iter = db.newIterator();
for (iter.seek('key'); iter.valid(); iter.next()) {
// There are also *Buf version to access iterators' keys & values.
console.log(`iterating: "${iter.keyStr()}" / "${iter.valueStr()}"`);
}
// You need to close iterators when you are done with them.
// Iterators will throw an error if used after this.
iter.close();
db.close(); // Same for databases.
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
3.4.0
10 months ago
3.6.0
10 months ago
3.3.1
2 years ago
3.3.0
2 years ago
3.2.0
2 years ago
3.1.0
3 years ago
3.3.5
2 years ago
3.3.4
2 years ago
3.3.2
2 years ago
3.0.6
3 years ago
3.0.5
3 years ago
2.2.1
4 years ago
2.1.1
4 years ago
2.2.2
4 years ago
3.0.4
4 years ago
3.0.3
4 years ago
3.0.2
4 years ago
3.0.1
4 years ago
3.0.0
4 years ago
1.7.2
4 years ago
1.8.0
4 years ago
1.7.1
4 years ago
1.7.0
4 years ago
2.1.0
4 years ago
1.5.1
4 years ago
1.4.3
4 years ago
1.4.2
4 years ago
1.4.1
4 years ago
1.2.0
4 years ago
1.1.0
4 years ago
1.3.4
4 years ago
1.3.3
4 years ago
1.3.2
4 years ago
1.4.0
4 years ago
1.3.1
4 years ago
1.2.2
4 years ago
1.3.0
4 years ago
1.2.1
4 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago