Access 'DB Views' in query builder and NodeJS

I could recreate your problem on a new project. I will check the difference on older projects.

1 Like

I checked again and I realised that I only looked at my MS SQL databases. In MS SQL I see the views and in MySQL I don’t see them. Hmm… what about using a custom query and create the view as a library item within Wappler? Is this an option?
I often create the query in Navicat and then copy the query in the custom query in Wappler.

1 Like

That is a good workaround, but not something that is feasible in the long run.
The view allows me to use it anywhere I connect the DB, library is limited to Wappler.

bumping this request. please consider.

Bump

Unfortunately this is related to external dependency of KnexJS for the database manipulation.
And they have this issue open for a while now. I bumped it up - hopefully it will be picked up there by somebody.

1 Like

Seeing how this is pending for the last 4.5 years (!), I don’t think its coming anytime soon. :cry:
But, you never know. 2021 could be the year of good things. :crossed_fingers:

Anyways, if I were to use mysql package and create a custom module for this, is there any way to make use of global DB connection params for connection string?

3 posts were split to a new topic: Custom module (NodeJS) invoking database connection

Hello, I’ve figured out a workaround to be able to use psql views in Wappler (nodejs) + query builder. Let me know if you have any ideas to make it better.

Steps:

  1. Create a table with the exact same column definitions as the view you want to use and add a view suffix (ej: myViewName_view_).

  2. In Wappler go to Database Manager > click on the arrows icon to refresh the schema.

  3. The file “.wappler/targets/Development/databases/db.json” will be updated with the new table definition.

  4. On that file find the name of the new table (myViewName_view_) under schema.tables and manually remove the view suffix.
    **remember to repeat this step after doing a ‘database schema refresh’ in Wappler in the future. (you can “automate” this using the command (sed -i.bu ‘s/view//g’ ./.wappler/targets/Development/databases/db.json) *works in Mac.

  • you can add it as a script in your package.json
  1. Now you can go to any server action and use your postgres view with Wappler’s Query builder.

I hope this helps and let me know if there’s something I’m missing out.

I’m getting started with wappler + I fixed this workaround a few minutes ago so I haven’t tested it thoroughly.

Cheers,

Edd

1 Like

Maybe usign a custom query can do the trick… I’m exploring around. Let me know if there’s a good use case for this workaround or not. :man_shrugging:

Anything that will help people get around the limitation with views will be appreciated. But take into account that there are certain users that will not use workarounds under any circumstances. So you might find yourself fixing a problem for yourself and another user :slight_smile:

Thanks for the detailed workaround.
It looks a bit too much to be honest.
My primary use of views is for paged query. Will have to test this out next time the situation arises.

Don’t think knex is anywhere close to adding support for views. So workarounds are the only option.

It seems to logical solution to me, performs the same function and no need for hacks. Cant remember the last time i used a view in Wappler

This has been fixed in Wappler 3.7.5

1 Like

How’s that for timing? They must have had this in the works already :slight_smile:

1 Like

@George with the new Views, I assume we still need to create these externally, say in MySql Workbench? We can’t create views in the DB Manager?

Yes the views are view and use only for now :slight_smile:

1 Like

This topic was automatically closed after 44 hours. New replies are no longer allowed.