datasette / datasette-enrichments-quickjs

Enrich data with a custom JavaScript function
Apache License 2.0
1 stars 0 forks source link

Option to return JSON creating multiple columns #5

Closed simonw closed 6 months ago

simonw commented 6 months ago

It would be great to have an option where the JavaScript function could return an object, and the enrichment would then create and populate a column for every key in that object.

Would help for breaking up JSON data into separate columns.

simonw commented 6 months ago

For example I got this from datasette-paste importing a GeoJSON file:

CleanShot 2024-04-05 at 14 34 58@2x

simonw commented 6 months ago

Current UI:

CleanShot 2024-04-05 at 14 37 16@2x

I will copy the datasette-enrichments-re2 UI:

re

simonw commented 6 months ago

I'll call it "Output mode".

simonw commented 6 months ago

It worked! I ran this:

CleanShot 2024-04-05 at 15 11 50@2x

function enrich(row) {
  return row.properties
}

Producing this:

CleanShot 2024-04-05 at 15 12 59@2x