From 2731d37fe4f62b1ce9bfd7da09d1636082526fc2 Mon Sep 17 00:00:00 2001 From: the lemons Date: Tue, 6 Dec 2022 02:51:22 -0600 Subject: add lmdb.next and pairs(db) --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index dd0fdef..b63c4e3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ create a new environment handle and open the database at the `path`. returns the ### `lmdb.version()` returns the LMDB version as `major, minor, patch`. +### `lmdb.next(db, key)` +returns the next key-value pair after `key` in the database handle `db`, or the first key-value pair if `key` is `nil`. keys are ordered lexicographically. unlike `next`, this function does not work for traversal if, during traversal, keys are set to `nil`. (TODO: fix this somehow) + ### `env:txn_begin(write_enabled)` create a new transaction in the environment. if `write_enabled` is true, then the transaction may make modifications to the database. returns the transaction handle (`txn`) on success. @@ -32,9 +35,7 @@ flush buffers to disk. if `force` is `true`, a synchronous flush is performed ev close the environment. ### `txn:open(name, create)` -open a database in the environment. if multiple databases are to be used in the environment, `name` is the name of the database to open. otherwise, it should not be supplied. if `create` is true, the database is created if it does not exist. returns a database handle on success. - -the database handle behaves as a table that may be indexed with string keys and contains string values, read from the database. any changes made will be saved to the database when the transaction is committed. +open a database in the environment. if multiple databases are to be used in the environment, `name` is the name of the database to open. otherwise, it should not be supplied. if `create` is true, the database is created if it does not exist. returns a database handle (`db`) on success. ### `txn:drop(name)` delete the database `name` from the environment. (or clear the database, if `name` is not supplied) @@ -47,3 +48,12 @@ commit all operations of the transaction into the database. ### `txn:txn_begin()` create a nested transaction in the parent transaction. + +### `db[key]` +read the value of `key` from the database. + +### `db[key] = value` +write `value` as the value of `key` into the database. + +### `pairs(db)` +returns `lmdb.next, db, nil`. -- cgit v1.2.3