Open f8k8 opened 5 years ago
hm, might be useful. This is similar to nestTables
flag, right? https://github.com/mysqljs/mysql#joins-with-overlapping-column-names
Usually I'm trying to resist new api as much as possible because it's much harder to remove later so don't expect quick decision on this
Would it be easy to integrate to mysqljs/mysql if they want it as well?
It is similar to the nestTables
flag, but gives you a bit more control over how your final object is laid out. The current implementation is either / or - I.e. you can't enable both nestTables
and processDots
, as they'd probably conflict.
I've just had a quick look through mysqljs/mysql and it looks like it should be pretty straightforward to add. The feature is implemented in a similar way to nestTables
- in the parser it pre-allocates all the fields in the object then just converts fields with .
in them (e.g. field.sub1.sub2
) into this[field][sub1][sub2]
.
We've added (albeit in an older fork of the library) an option to allow the library to process
.
in field names into objects. For example:SELECT table1.id, table2.fieldA as `foo.fieldA`, table2.fieldB as `foo.fieldB`, table1.anotherField
Would normally select the values into columns named:With the option enabled, the returned rows have the object format:
Would there be any interest in having this as a feature in the library? If so, we can tidy it up / rebase to the latest version and create a pull request.