We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to find a simple way to add pagination meta data to all my index actions, e.g. the total amount of entries and the current offset.
Other JSON API servers add this by default, e.g. jsonapi-server:
"meta": { "page": { "limit": 50, "offset": 0, "total": 4 } }
In a discussion on Gitter, @zacharygolba has proposed the following interim solution:
export const addMetaData = model => (req, res, data) => model.count().then(total => ({ ...data, meta: { total }, }))
import { Controller } from 'lux-framework' import User from '../models/user' import addMetaData from '../utils/add-meta-data' export default class UsersController extends Controller { afterAction = [ addMetaData(User), ] }
But this means that the query is run twice in order to determine the total amount of entries in addMetaData().
addMetaData()
Ideally, there would be a way to access the data gathered from queries in actions after they are executed.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am trying to find a simple way to add pagination meta data to all my index actions, e.g. the total amount of entries and the current offset.
Other JSON API servers add this by default, e.g. jsonapi-server:
In a discussion on Gitter, @zacharygolba has proposed the following interim solution:
But this means that the query is run twice in order to determine the total amount of entries in
addMetaData()
.Ideally, there would be a way to access the data gathered from queries in actions after they are executed.
The text was updated successfully, but these errors were encountered: