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
203 stars 14 forks source link

Chaining delete with query #34

Closed jmatsushita closed 7 years ago

jmatsushita commented 7 years ago

From #32

Finally, being able to use the query interface with filters and joins to delete would be nice. Maybe using the chaining syntax? Maybe using .get() instead of toArray would make a .del() fit nicely at the end of the chain?

jacoscaz commented 7 years ago

@jmatsushita which of the following would you like to see implemented?

  1. store.query().del()
  2. store.del(store.query().toArray())?

I feel option n. 2 is cleaner and almost identical to the .remove()method from the RdfStore class, so I would be inclined to go with that. Actually, option number 2. should already work. I need to write tests for it.

I edited this comment a bunch of times as writing it made me look at the API from a different perspective.

jmatsushita commented 7 years ago

Ah yes, I was thinking 1 because it looks nicer but I can live with 2 especially if its close to the RDFJS API!

jacoscaz commented 7 years ago

@jmatsushita we've incorporated your suggestions within a bigger refactor of the whole API as we were not 100% happy about it and wanted to reach a more stable version of it before starting to use node-quadstore internally. You can now do either of the following:

  1. store.query().del((err) => {})
  2. store.delStream(store.query().getStream(), (err) => {})

Closing this one, bugs should go into dedicated issues.