Open roberto-belardo opened 9 years ago
You should define which data you want to have in metadata in the Server side. Example:
SearchSource.defineSource('meals', function(searchText, options){
var options = options ? options : {sort: {_id: -1}, limit: 5};
var selector = {}
if (searchText){
var regExp = buildRegExp(searchText);
selector = {$or: [
{title: regExp},
{description: regExp}
]};
}
var query = Tours.find(selector, options);
return {
data: query.fetch(),
metadata: {count: query.count()}
}
});
...
@Kostanos: That worked perfect for me. Thanks.
+1 @Kostanos This also worked for me. Thanks!
+1 @Kostanos Thank you!
Hi, I tried to use the API getMetadata to get the number of results for a certain search but I can get it working. Could you provide a working example?
I defined an helper:
I defined a server searchSource:
And i am calling the search in the helper at the keyup as in you example:
But i cannot get the metadata. In the browser console i get an empty metadata object. If i uncomment the getMetadata() call in the searchSource server side definition I get a getMetadata is not defined.
Could you help me understand where is the error?
Thank you for your great job!