We are using js-data-sql
DSSqlAdapter in our backend nodejs service.
Our model definition has a hasOne
Relationship defined as follows:
module.exports = {
name: 'covariance_predictions',
idAttribute: 'id',
relations: {
belongsTo: {
assets: {
localKey: 'asset_1_id',
localField: 'Covariance_Predictions'
}
},
hasOne: {
currencies: {
localField: 'currency',
localKey: 'currency_id'
}
}
}
};
We call the adapter using:
covariancePredictions.findAll(params, {
with: ['currencies']
})
Question
After enabling knex
debugging, we figured out, that it does not use a left join
statement, but a subsequent SQL query like:
sql: 'select "currencies".* from "currencies" where "id" in (?, ?, ?, ?, ?, ?, ?)' }
Does anyone has any idea how to make js-data-sql
DSSqlAdapter build a left join
instead? Like:
select "covariance_predictions".id, [...], "currencies".code from "covariance_predictions" left join "currencies" on "currencies".id = "covariance_predictions".currency_id;