Transform between normalized database rows and nested JSON
- Source:
Methods
(static) rowToSchema(row, schema, keynullable) → {object}
Transform normalized database row to JSON. This function DOES NOT support arrays inside the object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
row |
Row | flat object returned by database |
|
schema |
JSONSchema | object indicating the format of final json object |
|
key |
string |
<nullable> |
only used in the function's recursion for non-object values (do not use for objects - it is ignored) |
- Source:
- To Do:
-
- add support for `x-sqlcolumnname` field for key lookup when names aren't the same
- enforce required fields?
- type validation?
- general JSON schema validation?
Returns:
inflated (now nested) json object complaint with the provided schema
- Type
- object