cult-of-coders / grapher-react

Provides easy to use React Components that are suitable for grapher package.
https://atmospherejs.com/cultofcoders/grapher-react
39 stars 19 forks source link

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

Open FrancoisYu opened 4 years ago

FrancoisYu commented 4 years ago
  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);