I am saving a hex string using levelup in a Node.js application.
const levelUP = require('levelup');
const levelDown = require('leveldown');
const db = levelUP(levelDown('./names.db'), (er, up) => {
if (er) { return; }
let id = 'id3';
let hex = '5aeb8824b68cd4a3aa4f2fd0cd8';
console.log('Saving:', hex);
db.put(id, hex).then(() => {
db.get(id).then(value => {
console.log('Loaded:', value);
});
});
});
The value in put
is of course a string, and even typeof hex
returns string
. The value returned from the get is an Uint8Array. The values of those bytes are correct I guess, if the hex was treated as a simple string (rather than hex encoded byte array). It makes no sense however as the documentation states otherwise. What could be wrong?