mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
shape_arrayfirst for query view
This commit is contained in:
parent
6f903d5a98
commit
fdb141f622
1 changed files with 7 additions and 1 deletions
|
|
@ -941,11 +941,17 @@ async def query_view(
|
||||||
return {"ok": False, "error": str(error)}
|
return {"ok": False, "error": str(error)}
|
||||||
return [dict(r) for r in results.rows]
|
return [dict(r) for r in results.rows]
|
||||||
|
|
||||||
|
async def shape_arrayfirst(_results):
|
||||||
|
results, error = _results
|
||||||
|
if error:
|
||||||
|
return {"ok": False, "error": str(error)}
|
||||||
|
return [r[0] for r in results.rows]
|
||||||
|
|
||||||
shape_fn = {
|
shape_fn = {
|
||||||
"arrays": shape_arrays,
|
"arrays": shape_arrays,
|
||||||
"objects": shape_objects,
|
"objects": shape_objects,
|
||||||
"array": shape_array,
|
"array": shape_array,
|
||||||
# "arrayfirst": shape_arrayfirst,
|
"arrayfirst": shape_arrayfirst,
|
||||||
# "object": shape_object,
|
# "object": shape_object,
|
||||||
}[_shape or "objects"]
|
}[_shape or "objects"]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue