LevelDB - Browser-Level: Any way to create one IndexDB database and several object storage under it trough the API?

30 views Asked by At

I am exploring the LevelDB abstract API, I like the idea to write one code for both the browsers and the server-side Node.

The question is, is there a way to have a cleaner IndexedDB structure, if my app needs several named key-value stores. With Level API, can I somehow command the browser to create, say, one IndexDB database with two "object store" under it?

As a new user of this technology I was naively expecting it to use the first "sublevel" or to respect the "/" character in a database name.

(And while at it, is this database abstraction relevant these days?)

import { Level } from 'level'

async function main () {
  const db = new Level('db/try')
  const output = document.getElementById('output')

  await db.put('beep', 'boop')
  output.textContent = await db.get('beep')

  var db2 = db.sublevel('tratata');

  await db2.put('beep2', 'boop2')
  output.textContent = await db2.get('beep2')
}

main()
0

There are 0 answers