node-lmdb | Node.js binding for lmdb | Runtime Evironment library
kandi X-RAY | node-lmdb Summary
kandi X-RAY | node-lmdb Summary
Just like with any other node module, the first step is to require() the module. Env represents a database environment. You can create one with the new operator and after that, you must open it before you can use it. open() accepts an object literal in which you can specify the configuration options for the environment. Close the environment when you no longer need it. An environment (Env) can contain one or more databases. Open a database with env.openDbi() which takes an object literal with which you can configure your database. Close the database when you no longer need it. The basic unit of work in LMDB is a transaction, which is called Txn for short. Here is how you operate with your data. Every piece of data in LMDB is referred to by a key. You can use the methods getString(), getBinary(), getNumber() and getBoolean() to retrieve something, putString(), putBinary(), putNumber() and putBoolean() to store something and del() to delete something. IMPORTANT: always close your transactions with abort() or commit() when you are done with them. You can batch together a set of operations to be processed asynchronously with node-lmdb. Committing multiple operations at once can improve performance, and performing a batch of operations and using sync transactions (slower, but maintains crash-proof integrity) can be efficiently delegated to an asynchronous thread. In addition, writes can be defined as conditional by specifying the required value to match in order for the operation to be performed, to allow for deterministic atomic writes based on prior state. The batchWrite method accepts an array of write operation requests, where each operation is an object or array. If it is an object, the supported properties are: * db (required) - The database to write to * key (required) - The key to write * value (optional) - If specified, this is the value to put into the entry. If absent or undefined, this write operation will be a delete, and delete this key. This should be a binary/buffer value. * ifValue (optional) - If specified, the write operation (put or delete) will only be performed if the provided ifValue matches the existing value for this entry. This should be a binary/buffer value. * ifExactMatch (optional) - If set to true, the conditional write requires that ifValue exactly match the existing value, byte for byte and length. By default ifValue can be a prefix and only needs to match the number of bytes in ifValue (for example if ifValue is Buffer.from([5, 2]), the conditional write will be performed if the value starts with 5, 2). * ifKey (optional) - If specified, indicates the key to use for for matching the conditional value. By default, the key use to match ifValue is the same key as the write operation. * ifDB (optional) - If specified, indicates the db to use for for matching the conditional value. By default, the key use to match ifValue is the same db as the write operation. If the write operation is a specified with an array, the supported elements are: * A three element array for put`ing data: `[db, key, value] (where value is a binary/buffer) * A two element array for del`eting data: `[db, key] * A four element array for conditionally put`ing or `del`eting data: `[db, key, value, ifValue] (where value and ifValue are as specificied in the object definition).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of node-lmdb
node-lmdb Key Features
node-lmdb Examples and Code Snippets
Community Discussions
Trending Discussions on node-lmdb
QUESTION
Actually im using SQlite to store some list of "files" with some attributes, no relational data only one file with multiple data, so i think any relational or nosql DB is valid for me. The problem right now is the Speed of the searchs, I need to embed the db using Node and storing a file in the project folder, actually im using node sqlite3, but i tested yerterday the better-sqlite3 module to, and the results are similar.
My table structure is like this:
...ANSWER
Answered 2017-Sep-22 at 08:40The performance is quite good and for your use case it looks to be an ideal one. I could achieve 1,000,000 rows/sec per client.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-lmdb
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page