add selector functionality to generate script

This commit is contained in:
2021-08-28 19:00:49 +02:00
parent 4ec28e6064
commit a63076c07c
4 changed files with 57 additions and 19 deletions

View File

@ -20,7 +20,8 @@ with open(args.schema) as schemaFile:
schema = json.load(schemaFile)
for table in schema["tables"]:
for column in table["columns"]:
columns = table["columns"]
for column in columns:
if column["sqltype"] == 'serial':
column["apitype"] = 'integer'
column["jstype"] = 'number'
@ -39,6 +40,7 @@ for table in schema["tables"]:
elif column["sqltype"].startswith('numeric'):
column["apitype"] = 'number'
column["jstype"] = 'number'
table["selectors"] = [ y["name"] for y in sorted([ x for x in columns if "selector" in x ], key=lambda x: x["selector"])]
for f in glob.glob(args.template):
print(f"process {f}")