zazuko / query-rdf-data-cube

Explore or query RDF Data Cubes with a JavaScript API, without writing SPARQL.
https://zazuko.github.io/query-rdf-data-cube/
9 stars 2 forks source link

Re-hydrate cube/datset from JSON #12

Closed jstcki closed 5 years ago

jstcki commented 5 years ago

Is there a way to re-hydrate a DataCube/DataSet from JSON?

My use case I might want to fetch datasets (+ metadata) server-side, and send it to the client, where I want to query for observations. Ideally without having to re-fetch the whole metadata again.

This also relates to my comment in #11. When filtering by graph is not done on the query level, a lot of unneeded stuff might end up in the cache of a cube which I wouldn't want to serialize to JSON.

An alternative to re-hydrating/creating new DataSet instances would be a more statless FP-style API where I can just use data to fetch more. E.g. getDimensions(datasetIri: string): Dimension[].

vhf commented 5 years ago

There's no direct way of doing this at the moment but it should be easy to implement. The use case you describe is something we want to support.

I didn't put any thought to it yet but here's the plan off the top of my head:

vhf commented 5 years ago

The following classes now have a #toJSON and a .fromJSON: DataCube, DataSet, Component/Dimension/Measure/Attribute.

(v0.0.4)