shape_arrayfirst for query view

prototype-json-context-docs
Simon Willison 2023-05-08 17:51:29 -07:00
rodzic 6f903d5a98
commit fdb141f622
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -941,11 +941,17 @@ async def query_view(
return {"ok": False, "error": str(error)}
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 = {
"arrays": shape_arrays,
"objects": shape_objects,
"array": shape_array,
# "arrayfirst": shape_arrayfirst,
"arrayfirst": shape_arrayfirst,
# "object": shape_object,
}[_shape or "objects"]