💡 Wishful Thinking - Database Views

I would love to publish this document as a result of this Feature Request being implemented

Please Vote now!


:hammer_and_wrench: Steps to Create a Database View in Wappler

1. Open the Database Manager

  • In Wappler, go to the Database Manager panel.
  • Make sure your database connection is already configured (MySQL, MariaDB, PostgreSQL, etc.).

2. Switch to the Database Structure

  • Expand your target database.
  • You’ll see Tables, Views, Changes, Seeds (depending on your DB type).

3. Add a New View

  • Right‑click on Views → select New View.
  • Wappler will open a SQL editor window.

4. Define the View with SQL

  • Enter your SQL CREATE VIEW statement.
    Example (MySQL/Postgres style):
CREATE VIEW employee_summary AS
SELECT 
    e.id,
    e.first_name,
    e.last_name,
    d.department_name,
    COUNT(p.project_id) AS project_count
FROM employees e
JOIN departments d ON e.department_id = d.id
LEFT JOIN projects p ON e.id = p.employee_id
GROUP BY e.id, d.department_name;
  • This creates a reusable view that joins employees, departments, and projects.

5. Save & Refresh

  • Click Save in Wappler.
  • The new view will now appear under Views in the Database Manager.
  • You can query it just like a table in your Server Actions or API workflows.

KeepDreamingGIF

1 Like

Wait! Wappler now supports views!? Is that what I am reading?

Edit: Just saw the wishful thinking part and it clicked in. Maybe if enough of us wish it ….

1 Like

Wappler supports views in that they are visible but has no method of creating them, they have to be created externally.
May research if i can make an extension that can take a Wappler query and create a view from it. Will depend if Knex() offers such functionality.

1 Like

Does this help?

exports.up = function (knex) {
    // Define driver constants
    const isPG = knex.client.constructor.name.startsWith('Client_PG');
    const isMSSQL = knex.client.constructor.name.includes('MSSQL');
    const isMySQL = knex.client.constructor.name.includes('MySQL');
    const isSQLite = knex.client.constructor.name.startsWith('Client_SQLite3');

    // Create the employee_activation_details view
    const createViewSQL = `
    CREATE VIEW employee_activation_details AS
    SELECT 
      eam.*,
      e.first_name,
      e.last_name
    FROM employee_activation_management eam
    JOIN employees e ON eam.employee_id = e.id
  `;

    return knex.raw(createViewSQL);
};

exports.down = function (knex) {
    // Define driver constants
    const isPG = knex.client.constructor.name.startsWith('Client_PG');
    const isMSSQL = knex.client.constructor.name.includes('MSSQL');
    const isMySQL = knex.client.constructor.name.includes('MySQL');
    const isSQLite = knex.client.constructor.name.startsWith('Client_SQLite3');

    // Drop the view - most databases use the same syntax
    const dropViewSQL = 'DROP VIEW IF EXISTS employee_activation_details';

    return knex.raw(dropViewSQL);
};

Thanks Ben, already been looking into that sort of thing.

Rather than manually creating knex() migration files, i was thinking of an extension where you can pass a query to it and it creates the view from that automatically via knex.schema.createViewOrReplace()