LevelDB wrapper for Nim
Go to file
benbierens 90f998333a
removing unnecessary files
2024-05-09 11:58:18 +02:00
.github/workflows working on buildscript 2024-05-09 11:01:21 +02:00
sources@99b3c03b32 copy in submodule and build.sh 2024-05-09 10:18:06 +02:00
src switch to CatchableError (#24) 2021-02-03 13:17:56 +08:00
tests fix warning since nim 1.4.0 2021-02-08 17:06:50 +08:00
.gitignore csize is deprecated in nim 1.2 2020-07-20 00:46:37 +08:00
.gitmodules copy in submodule and build.sh 2024-05-09 10:18:06 +02:00
.travis.yml supported since nim 1.4.0 (#25) 2021-02-03 13:19:14 +08:00
LICENSE Initial commit 2016-05-17 21:31:18 +02:00
README.md add document link 2020-06-24 11:46:49 +08:00
build.sh removing unnecessary files 2024-05-09 11:58:18 +02:00
leveldb.nimble release version 0.4.1 2021-02-08 17:25:01 +08:00

README.md

leveldb.nim

docs

A LevelDB wrapper for Nim in a Nim friendly way.

Create a database:

   import leveldb
   import options

   var db = leveldb.open("/tmp/mydata")

Read or modify the database content:

   assert db.getOrDefault("nothing", "") == ""

   db.put("hello", "world")
   db.put("bin", "GIF89a\1\0")
   echo db.get("hello")
   assert db.get("hello").isSome()

   var key, val = ""
   for key, val in db.iter():
     echo key, ": ", repr(val)

   db.delete("hello")
   assert db.get("hello").isNone()

Batch writes:

   let batch = newBatch()
   for i in 1..10:
     batch.put("key" & $i, $i)
   batch.delete("bin")
   db.write(batch)

Iterate over subset of database content:

   for key, val in db.iterPrefix(prefix = "key1"):
     echo key, ": ", val
   for key, val in db.iter(seek = "key3", reverse = true):
     echo key, ": ", val

   db.close()