{"action":"created","issue":{"url":"https://api.github.com/repos/feathersjs/feathers/issues/310","repository_url":"https://api.github.com/repos/feathersjs/feathers","labels_url":"https://api.github.com/repos/feathersjs/feathers/issues/310/labels{/name}","comments_url":"https://api.github.com/repos/feathersjs/feathers/issues/310/comments","events_url":"https://api.github.com/repos/feathersjs/feathers/issues/310/events","html_url":"https://github.com/feathersjs/feathers/issues/310","id":150755337,"number":310,"title":"Subscribe and unsubscripbe to rethinkDb change feed","user":{"login":"syvuilliot","id":1689880,"avatar_url":"https://avatars.githubusercontent.com/u/1689880?v=3","gravatar_id":"","url":"https://api.github.com/users/syvuilliot","html_url":"https://github.com/syvuilliot","followers_url":"https://api.github.com/users/syvuilliot/followers","following_url":"https://api.github.com/users/syvuilliot/following{/other_user}","gists_url":"https://api.github.com/users/syvuilliot/gists{/gist_id}","starred_url":"https://api.github.com/users/syvuilliot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syvuilliot/subscriptions","organizations_url":"https://api.github.com/users/syvuilliot/orgs","repos_url":"https://api.github.com/users/syvuilliot/repos","events_url":"https://api.github.com/users/syvuilliot/events{/privacy}","received_events_url":"https://api.github.com/users/syvuilliot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/feathersjs/feathers/labels/Feature","name":"Feature","color":"207de5"},{"url":"https://api.github.com/repos/feathersjs/feathers/labels/Proposal","name":"Proposal","color":"F4A177"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-25T05:46:57Z","updated_at":"2016-04-26T13:37:51Z","closed_at":null,"body":"Hello all,\r\n\r\nI'm quitte new to feathers but I like the approach and I really enjoyed reading the doc which is really high quality.\r\nFor what I have seen, the real time aspect of feathers is provided by emitting 'events' when there is a change on a collection (table). But if I want to only listen to changes made on a small scope of the collection (say the last 10 messages sent by Alice with 'unread' status) I have to do the filtering on the client side which is quitte inefficient (since it is a dynamic query, it can't be done server side actually).\r\n\r\nBeacause that's the sort of thing, rethinkDb was made for, I would like to be able to leverage this feature via feathers. But the challenge is the ability to subscribe and unsubscribe from query.\r\n\r\nWhat would be the best approach to do it ?\r\n\r\nI thought about 2:\r\n1) add 'watch' and 'unwatch' methods on services, but as far as I know, we cannot add 'custom' methods to services. Perhaps should we add them as 'official' optional (depending on the db) methods ?\r\n2) create a service that allow to 'create' and 'remove' subscriptions to another service. Like a 'messages/subscriptions' service that allow to 'create' a query subscription on a 'messages' service\r\n\r\nI know this would only work with rethinkDb since it is the only real time database able to handle this type of subscription to a query but I think, this is a right approach to real time and feathers would benefit from supporting it well in its architecture. And perhaps could it be used with others db with change feeds like couchDb and mongoDb.\r\n\r\nThanks all for your answers\r\n\r\nSylvain"},"comment":{"url":"https://api.github.com/repos/feathersjs/feathers/issues/comments/214747382","html_url":"https://github.com/feathersjs/feathers/issues/310#issuecomment-214747382","issue_url":"https://api.github.com/repos/feathersjs/feathers/issues/310","id":214747382,"user":{"login":"marshallswain","id":128857,"avatar_url":"https://avatars.githubusercontent.com/u/128857?v=3","gravatar_id":"","url":"https://api.github.com/users/marshallswain","html_url":"https://github.com/marshallswain","followers_url":"https://api.github.com/users/marshallswain/followers","following_url":"https://api.github.com/users/marshallswain/following{/other_user}","gists_url":"https://api.github.com/users/marshallswain/gists{/gist_id}","starred_url":"https://api.github.com/users/marshallswain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marshallswain/subscriptions","organizations_url":"https://api.github.com/users/marshallswain/orgs","repos_url":"https://api.github.com/users/marshallswain/repos","events_url":"https://api.github.com/users/marshallswain/events{/privacy}","received_events_url":"https://api.github.com/users/marshallswain/received_events","type":"User","site_admin":false},"created_at":"2016-04-26T13:37:51Z","updated_at":"2016-04-26T13:37:51Z","body":"Another (maybe possible) option would be to use a custom attribute like `{$subscribe: true}` and `{$subscribe: false}` to grant some more granularity in per-query control of subscriptions."}}