kriszyp / lmdb-js

Simple, efficient, ultra-fast, scalable data store wrapper for LMDB
Other
505 stars 42 forks source link

doesExist returns false after writing empty buffer with binary encoding #52

Closed mischnic closed 3 years ago

mischnic commented 3 years ago
import * as lmdb from "lmdb-store";
let store = lmdb.open("cache", {
   name: "cache",
   encoding: "binary",
});

console.log(store.doesExist("x"));
console.log(store.get("x"));
await store.put("x", Buffer.from(""));
console.log(store.doesExist("x"));
console.log(store.get("x"));

prints

false
undefined
false
<Buffer >

With an non-empty buffer, it works correctly:

false
undefined
true
<Buffer 61 62 63>
kriszyp commented 3 years ago

Should be fixed in v1.5.3

mischnic commented 3 years ago

👍