I got two tables: 'page' and 'page_css'. I want a one to many relationship between page and page_css (one page contains multiple page_css). See table structure:
This is the Knex query I am using:
var page = knex('page')
.where({ slug: req.params.slug })
.join('page_css', { 'page_css.page_id': 'page.id' })
.then(function(page) {
if (page) {
return res.json(page);
}
return res.send('page not found');
});
This the result I'm getting:
But I want the result like this:
What SQL/Knex query do I need to run to get it like the format above?