For the post "DB-tables, One snippet to call them all #2 : Benihikō"
Because I need to show the Tables INSIDE the snippet
22Char ID of your DB table
{formtext: name=Table_id; default=22Char ID of your DB table; cols=22}
{urlload: https://data-api.blaze.today/api/database/fields/table/{=table_id}/; done=(res) -> ["Data":(res)]}
{Resulta=lower(fromjson({=Data}))}{liste=[n.name for n in resulta]}{=liste}
The {urlload command still doesn't work in community snippet (it'll work in your dashboard with your own table id) so we'll use this simulated respsonse to continue
{mlist=["product_name", "color", "price", "origin", "lenght", "motto"]}mlist={=mlist}
------------------------
Bringing back the formmenus:
Single choice:
{=onefield}
{formmenu: values={=mlist}; name=onefield; multiple=no}
------------------------
Multiple choices no formatter:
{=several_fields}
{formmenu: values={=mlist}; name=several_fields; multiple=yes}
------------------------
Onefield={list_onefield=[onefield]}{=list_onefield}
Several_fields={=several_fields}
------------------------
One record:
{dbselect: SELECT product_name, Color, Price, Origin, Lenght, motto FROM Mock_Data; space=7JxI3mdWKF1JE6iC4hlZGp; menu=yes; name=OneRow; multiple=no}{list_onerow=[onerow]}
---
one record/single field = {=[[OneRow[{=onefield}]]]}
one records/several fields = {=[[OneRow[f] for f in several_fields]]}
------------------------
Several record:
{dbselect: SELECT product_name, Color, Price, Origin, Lenght, motto FROM Mock_Data; space=7JxI3mdWKF1JE6iC4hlZGp; menu=yes; name=MultiRowS; multiple=yes}
----
multiple records/single field (list manipulation)= {=[[r[onefield] for r in MultiRowS]]}
multiple records/several fields (list manipulation) =Repeat={repeat: for r in MultiRowS}{=[r[f] for f in several_fields]}{endrepeat} We're ditching the {repeat} command for another list manipulation, for consistents outputs
={=[[r[f] for f in several_fields] for r in multirows]}
------------------------------------------------------------------------
UNIFORMIZATION:
| first formula | converted but not working | working | Complete |
multirow/several fields | {=[[r[f] for f in several_fields] for r in multirows]} | | | {=[[r[f] for f in several_fields] for r in multirows]} |
Multirows/onefield | {=[[n[onefield] for n in MultiRowS]]} (the only exception in its form, so far) | {=[[r[f] for f in onefield] for r in multirows]} | {=[[r[f] for f in [onefield]] for r in multirows]} | {=[[r[f] for f in list_onefield] for r in multirows]} |
Onerow/onefield | {=[[OneRow[{=onefield}]]]} | {=[[r[f] for f in onefield] for r in onerow]} | {=[[r[f] for f in [onefield]] for r in [onerow]]} | {=[[r[f] for f in list_onefield] for r in list_onerow]} |
onerow/several fields | {=[[OneRow[n] for n in several_fields]]} | you get the idea | you get the idea | {=[[r[f] for f in several_fields] for r in list_onerow]} |