aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 137 forks source link

Server side filtering on _id? #431

Open s7dhansh opened 8 years ago

s7dhansh commented 8 years ago

Is it not available? Or am I doing something wrong?

It works on every other field but when I use the "_id" field, I does not filter, but returns everything.

s7dhansh commented 8 years ago

I assume it is this line: https://github.com/aslagle/reactive-table/blob/master/lib/reactive_table.js#L163

@aslagle can you please explain the logic, and if/how we can achieve this. The use case is to to use a reactive table to show a selected set of documents, whose ids are achieved through aggregation or otherwise, eg. in case of reports where clicking on counts can open a list view of those specific documents.

aslagle commented 8 years ago

The line you linked to isn't used for server-side filtering. It's for automatically getting fields from an item in the collection if there weren't any fields in the settings. To use server-side filtering it's required to put fields in the settings, so it wouldn't get there.

I don't think there's anything in the code that would prevent using '_id' as a filter field - it should work just like any other field.

s7dhansh commented 8 years ago

@aslagle oh ok. So I dug deeper and found out the issue. I am publishing some specific fields only, and since _id is published by default, I did not put it in the field list. Due to this block, https://github.com/aslagle/reactive-table/blob/master/lib/filter.js#L57, the built query contains only those fields that are present in publishing list.

It is a pretty grey area, so would you consider it as a bug and accept a PR?

aslagle commented 8 years ago

Yes, I think that makes sense. If it's published by default it should also be filterable by default.