Как использовать таблицу в качестве столбца внутри .select () в knex.js - PullRequest
0 голосов
/ 11 ноября 2019

У меня есть запрос, подобный приведенному ниже:

knex('some_table')
.innerJoin('stockcurrent','some_table.id','stockcurrent.id')
.select('id','units',
   knex.raw(`array_to_string(array(select sp.purchaseprice 
        from stockcurrent_part as sp 
        where sp.product = stockcurrent.product 
        and sp.company = ${req.userData.company} 
        and sp.date in (select min(sp2.date)
            from stockcurrent_part as sp2
            where sp2.product = stockcurrent.product
            and sp2.company = ${req.userData.company})
        ),',  ') as cost`))

он выдает ошибку в сети, но не указывает на ошибку. Но когда я использую значения вместо sp2.product = 19222 и sp2.company = 18, это работает.

...