I use knex and a bookshelf, and my table consists of the author, title, content, count, and each information looks like this:
author: 'John Doe',
title: 'aaaaa',
content: 'aaaaaaaa'
count: 54,
I want to get data based on count value, and I want to get 4 data with the highest count value.
If I want to get all the data, I do like this:
router.get('/', (req, res) => {
Article.forge().fetchAll().then(article => {
res.json(article);
})
})
Is there a way that I can do like forge({ count: 3 data that has the highest count value })or
What should I add code so that I can do this?
source
share