reactive-table icon indicating copy to clipboard operation
reactive-table copied to clipboard

Server side filtering on _id?

Open s7dhansh opened this issue 9 years ago • 4 comments

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 avatar Sep 23 '16 06:09 s7dhansh

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.

s7dhansh avatar Sep 23 '16 07:09 s7dhansh

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.

aslagle avatar Sep 24 '16 14:09 aslagle

@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?

s7dhansh avatar Sep 24 '16 15:09 s7dhansh

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

aslagle avatar Sep 24 '16 15:09 aslagle