mantra-sample-blog-app
mantra-sample-blog-app copied to clipboard
How to send params to container from component ?
we have save query like: {_id: id}, {limit: 10} ... how to send them to container query from server side?
Could you add more information to this?
we have container:
function composer(props, onData) {
const handle = Meteor.subscribe('categories');
if(handle.ready()) {
const categories = Categories.find({}, {sort: {_id: 1}}).fetch();
onData(null, {categories});
};
};
how to find:
const categories = Categories.find({_id: id}, {limit: limit, skip: skip}).fetch();
more: this good featured from laravel: it can return pagination object from server:
{
data: {...},
current_page: 1,
last_page: 5,
...
}
in Meteor, can we do this ? thanks so much !
@lyquocnam Are you talking about this: http://docs.meteor.com/#/basic/Mongo-Collection-find
yeah but my problem is how to send params to it from component. this query in container. and how to server can send pagination object to client, this will be simpler many times i guess, thanks @xcv58 nice to meet u !
@lyquocnam why not use LocalState to store the mongo selectors?
@sammkj i'm new so i dont' know about that... not any tuts from this ? @@ thanks @sammkj
@lyquocnam uhm. I'm in the process of learning as well. haha.
I use URL params to do filtering. For example, www.example.com/categories?type=shoe&stars=5
. Then I use FlowRouter's API to retrieve the value.
Or you can set / update the LocalState / Session when user changes the filters. Perhaps this article might help you.
i used URL params. this work ! any solution about get pagination object from server like laravel ?
{
data: {...},
current_page: 1,
last_page: 5,
...
}
thanks @sammkj !
@lyquocnam I don't have any experience with Laravel. For pagination, you will need to count all the documents and do all the pagination stuffs by yourself or you can use meteor packages like this one
Ya, i can custom a pagination use for react by publishCount from server. but i try to find better solutions for this and laravel resolved this good. i trying to do like that. thanks @sammkj , you are the best :+1:
When talking about vanilla Mantra with ReactiveDict as LocalState, answer on your question will be to create Action which set it. Than you can call that action from your Component to set value in the application logic. And when you use that value inside container to filter data it will work as you want.
thanks @ShockiTV i'll try :dancers: