how update any database value in knex
router.put('/:id', async (req, res) => {
const {id} = req.params;
const changes = req.body;
try {
const count = await db('posts').where({id}).update(changes);
if (count) {
res.status(200).json({updated: count})
} else {
res.status(404).json({message: "Record not found"})
}
} catch (err) {
res.status(500).json({message: "Error updating new post", error: err})
}
});