LevelDB wrapper for Nim
Go to file
Ben 1538f9a1da
fixes wrong LEVELDB_PLATFORM define
2024-05-13 11:38:49 +02:00
.github/workflows CI for different nim versions 2024-05-13 11:22:49 +02:00
build/include/port checking build for mac 2024-05-13 11:28:58 +02:00
leveldb fixes wrong LEVELDB_PLATFORM define 2024-05-13 11:38:49 +02:00
tests Fixes tests for windows 2024-05-10 14:28:55 +02:00
vendor@068d5ee1a3 Revert "pins leveldb to v1.23" 2024-05-11 08:08:44 +02:00
.gitignore moves sources to vendor directory 2024-05-09 14:49:59 +02:00
.gitmodules remove src folder 2024-05-09 15:37:37 +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 applies sed to passc and compile 2024-05-13 11:01:43 +02:00
leveldb.nim remove src folder 2024-05-09 15:37:37 +02:00
leveldb.nimble cleanup nimble file 2024-05-10 14:04:27 +02:00
leveldbtool.nim remove src folder 2024-05-09 15:37:37 +02: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()