Closed jstcki closed 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:
DataCube#toJSON
and DataCube#fromJSON
. Having these two methods on DataSet
as well isn't strictly necessary but it will probably make implementation easier, I guess I'll probably implement that as well.getDimensions(datasetIri: string): Dimension[]
idea as well while refactoring the caching. Having caches that don't duplicate "Components" while retaining info about what is in which dataset seems doable.The following classes now have a #toJSON
and a .fromJSON
: DataCube, DataSet, Component/Dimension/Measure/Attribute.
(v0.0.4
)
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[]
.