.where() 带条件逻辑

时间:2021-05-27 11:04:09

标签: bookshelf.js

Bookshelf.js 中,如何在 .where() 中实现一些条件逻辑?

其次,如何正确地将查询变量传递给它?

鉴于...

.query('location')
    .model.query(qb => {
        qb.join('locations', 'events.Location', 'locations.id')       
          .where(
            // some logic here, like:
            myFunction(
                { latitude: Latitude, longitude: Longitude },
                { latitude: ctx.query.Latitude, longitude: ctx.query.Longitude }
            ) >= 5000
        )
    })
    .fetch();

... 抛出一个错误,如:ReferenceError: Latitude is not defined

仅供参考,纬度和经度存在于“位置”中。

0 个答案:

没有答案
相关问题