使用 Knex.js 从 VIEWS 返回数据



如何使用knex从mysql数据库中的视图中获取数据.js?

我想在我的nodejs route.get中返回这些数据

SELECT c.id, nome_1 
  FROM pessoas_juridicas as pj
  INNER JOIN pessoas as p
      ON p.id = pj.pessoa_id
  INNER JOIN clientes as c
      ON c.pessoa_id = pj.pessoa_id
UNION 
SELECT c.id, nome_1 
  FROM pessoas_fisicas as pf
  INNER JOIN pessoas as p
      ON p.id = pf.pessoa_id
  INNER JOIN clientes as c
      ON c.pessoa_id = pf.pessoa_id
 WHERE p.id = 1
 ;
let sql = knex.from('live_calls' + ' as r')
        .select('r.uuid', 'r.destination', 'r.current_status', 'r.src')
        .where('r.uuid', '=', uuid );
  
    sql.then((response) => {
        console.log(response);
     });

这里live_calls是一个MySQL视图。

相关内容

  • 没有找到相关文章

最新更新