Published
Edited
Aug 25, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
groq(sampleData)`
* {
_id,
'image': {
${/* `asset` here refers to the parent document */ ''}
'src': asset.image.url
}
}
`
Insert cell
Insert cell
groq(sampleData)`
* {
_id,
'image': select(
defined(asset.image.url) => {
${/* `asset` here refers to the parent document */ ''}
'src': asset.image.url
},
null
)
}
`
Insert cell
Insert cell
Insert cell
groq = (dataset) => async (quasis, ...expressions) => {
const fullQuery = quasis.reduce((state, next, index) => `${state}${next}${expressions[index] || ''}`, '');
const tree = await groqjs.parse(fullQuery);
const stream = await groqjs.evaluate(tree, {dataset});
return stream.get();
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more