grapher-react icon indicating copy to clipboard operation
grapher-react copied to clipboard

How can I set a filter and a sort option to the createQuery

Open FrancoisYu opened this issue 5 years ago • 0 comments

  1. In the server, I setup a namedQuery:

const query = Company.createQuery({ country: 1, fullName: 1, shortName: 1, address: 1, timeZone: 1, $paginate: true, });

export default query;

  1. In the client, I import the query and try to added some filter and sort option, but cannot make it work:

import query from '/imports/api/company/query/getAllCompanies';

const CompaniesList = (props) => { console.log(props.data); }

export default withQuery(()=>{ const filters = [{ country: { $ne: '' } }]; const perPage = 25; const page=1;

const recordQuery = query.clone({ filters: { $and: filters }, sort: { country: 1 }, limit: perPage, skip: (page - 1) * perPage, });

return recordQuery; },{ reactive: true }, )(CompaniesList);

FrancoisYu avatar Mar 13 '20 15:03 FrancoisYu