quadstorejs / quadstore

A LevelDB-backed graph database for JS runtimes (Node.js, Deno, browsers, ...) supporting SPARQL queries and the RDF/JS interface.
https://github.com/quadstorejs/quadstore
MIT License
202 stars 14 forks source link

QOL: throw error on invalid backend parameter #140

Closed KonradHoeffner closed 2 years ago

KonradHoeffner commented 3 years ago

I made the mistake of using backend:memdown instead of backend:memdown()in the constructor of Quadstore:

...
import memdown from "memdown";
const store = new Quadstore({ backend:memdown, comunica: newEngine(), dataFactory: DataFactory});
...
await store.open();

However this only throws an error when calling store.open:

throw new Error(`Store is not ready (status: "${this.db.status}"). Did you call store.open()?`);
                  ^
Error: Store is not ready (status: "undefined"). Did you call store.open()?

And the error message does not point out that the db is in the wrong format. It would be helpful if the constructor would throw an error that the backend is invalid.

jacoscaz commented 3 years ago

Very good point @KonradHoeffner . I'll happily take a PR if you're able to but will do this myself if not. It's little things like this that cumulatively make life a lot easier for developers.

By the way, if you feel comfortable doing so, I'd be interested in hearing about your use-case for quadstore. Either privately or at https://github.com/beautifulinteractions/node-quadstore/discussions/112 .

KonradHoeffner commented 3 years ago

I'm unfortunately not familiar enough with the codebase to create a PR but I shared our use case in #112, thanks!

jacoscaz commented 2 years ago

Done, will be included in the next version.