Custom Plugin to transform Alias.* to "Alias.Column1", "Alias.Column2", etc.
Hi everyone, in the previous question, I asked how to transform the following syntax into a new one. I was adviced to create my own plugin serializer (example: https://github.com/subframe7536/kysely-sqlite-tools/tree/master/packages/plugin-serialize). However, I still struggle with how to do it. Can anybody please give me a hint? I'll do it later by myself but need a guide how to start.
Thank you very much!
input syntax:
required result:
7 Replies
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
you mean debug and checkout inside the plugin, right?
Kysely doesn't have the data required to convert
selectAll('Alias')
into select(['Alias.Column1', 'Alias.Column2'])
. Kysely only knows about Column1
, Column2
etc. in the type level. You need to provide that information yourself somehow.
You can't create a plugin that'd also make the types aware of the new Alias.Column1
and Alias.Column2
column names
TLDR; It's impossible to create this plugin.😢
I've created class called KyselyBroker which consumes compiled-query and do some dynamic post-processing based on additional parameters and options so the result is easier to use in other db frameworks or ORMs. It's not fancy but it works. This one is however more complex - it's not just replace
this
with that
. I'll think about it. The whole think is we have a huge implementation of sequelize already and we combine it (not replace) with Kysely. We use Kysely where Sequelize struggles.GitHub
GitHub - kysely-org/kysely-sequelize: A toolkit (dialect, type tran...
A toolkit (dialect, type translators, etc.) that allows using your existing Sequelize instance with Kysely. - kysely-org/kysely-sequelize
wow, I definitely haven't. I'll take a look for sure. Thank you
Getting some feedback would be great!