scttnlsn / backbone.io

Backbone.js sync via Socket.IO

Home Page:http://scttnlsn.github.io/backbone.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Best practise to data isolation

samhatoum opened this issue · comments

I'm loving this module more everyday, so a big thank you for all your efforts.

I need some help in understanding something. I hope this is the right place to post such questions.

I have an whiteboard application at foo.com and I'd like people to go to foo.com/mywhiteboard/ to access their personal board, after which they'll see all their board objects for that board.

Currently the board is syncing all objects nicely. I'd like to limit the objects syncing to be only those for that particular board. On the DB this is an easy filter, but I'm wondering what the best practise to use here is using backbone.io? How can I pass the req.params.id to every backbone sync so that I can see it in the req object that gets to the middleware? I can obviously do this directly on the model but I'm wondering if there's a better way?

Soon I'll need to secure the boards to logged in users with roles etc, so I'll be using an intermediate "auth" middleware to do this, before passing to next. Please keep this in mind with the answer.

Many thanks in advance.

I would recommend using channels for this sort of thing. You could have a separate channel for each board. https://github.com/scttnlsn/backbone.io#channels

Thanks for the response. Using channels has done the trick.

I think having an options object to pass to a backend independently of the model would be useful. For example to give hints to the middleware about which region to store some data. Obviously I can do this by creating a model wrapper but a suggestion for the future :)