const level = require('level')
const db = level('my-db')
const ops = [
{ type: 'get', key: 'block' },
{ type: 'get', key: 'b'+32, value: 'byte block hash' },
{ type: 'get', key: 'F+4', value: 'byte file number' },
{ type: 'get', key: 'I-4', value: 'byte file number' },
{ type: 'get', key: 't+32', value: 'byte transaction hash' }
]
db.batch(ops, function (err) {
if (err){
return console.log(err)
}
console.log('Great success')
})
The type is the type of the operation we want to do. They are the same as the method names.
The key is needed for getting the items to delete.
And the value is what we insert as the value of the key
Other additional functions include;
Get- get a key from the database
Put- put a value from the database
Del - delete a key in the current range
L.S- get all the keys in the current range
Start - defines the start of the current range
End - denfine the end of the current range
This will help you get to know leveldb better
https://bitcoindev.network/understanding-the-data/amp/
https://thewebdev.info/2020/09/21/node-js-basics%E2%80%8A-%E2%80%8Alevel-db/
https://imil.net/blog/posts/2020/bitcoin-leveldb-debugging/