Node.js bindings for a bplus C libarary
Both database engine and node.js bindings are in development now, use carefully.
npm install bplus
var bplus = require'bplus';var db = bpluscreateopen'/tmp/1.bp';dbset'key' 'value'dbget'key'console.log'voila! Key is in database: %s' value;dbclose;;;
Returns instance of database wrapper.
Associates database with file until
.close() will be called.
Stores key/value pair in database. Both
value arguments may be
Buffer. If write will fail, callback will receive
err as the
key is already in database - previous value will be
Searches database for
key and invokes callback with it's value (or error).
key may be a
Buffer or a
Note: Callback will also receive
ref as third argument, see MVCC part
below for details.
key from database or invokes callback with error if operation has
failed (callback will be called anyway upon completion).
Runs compaction on database. Will significantly reduce database size and increase speed of lookup and insertion.
Note: For big databases may take some time (~ 30 sec for a database with 1000000 records).
.set(), but if
key is already in database -
filter(previousValue, currentValue) will be called. Value will be replaced
only if return value of
filter is not
filter is called before removing actual value. Should
be used to ensure that only specific value will be removed.
Returns previous value of
callback will receive three arguments
Note: That after compaction
promise object that'll emit
message event for each key/value pair
found in specified range.
end will be emitted on stream finish.
var promise = dbgetRange'start' 'end';promiseon'message'// see `.get()` for details;promiseon'end'// Ended;
filter can be passed to load values only of specific keys. Value won't be
loaded (and emitted in
message event) only if filter returned
false for it.
dbgetRange'start' 'end'return keytoString === 'somekey';;
Inserts multiple key/values in one atomic operation.
var kvs =key: 'a'value: 'a'key: 'b'value: 'b';dbbulkkvs// .. your code ..;
.bulk, but with
filter as in
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2012.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.