diff options
author | ubq323 <ubq323@ubq323.website> | 2023-03-21 16:38:07 +0000 |
---|---|---|
committer | the lemons <citrons@mondecitronne.com> | 2023-04-04 21:48:59 -0500 |
commit | 241690fe5733e758166d8fcd52acaa5f2e505cb0 (patch) | |
tree | 9e6d02e83bcfff3403411bf79c2275c7e5808e34 | |
parent | ba9787994770dab80403ee21539bd5bbba912d47 (diff) |
add lmdb.pairs() for iteration on lua versions without __pairs metamethod
also fix minor formatting error in readme
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | lmdb.c | 1 |
2 files changed, 4 insertions, 3 deletions
@@ -55,8 +55,8 @@ 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`. +### `pairs(db)`, `lmdb.pairs(db)` +returns `lmdb.next, db, nil`, allowing iteration through all the key-value pairs of a database. the `lmdb.pairs` form works even on lua 5.1, which doesn't support the `__pairs` metamethod. -## `#db` +### `#db` return the number of entries in the database. @@ -361,6 +361,7 @@ static const struct luaL_Reg lmdb[] = { {"open", env_open}, {"version", version}, {"next", db_next}, + {"pairs",db_pairs}, {NULL, NULL}, }; |