3 ms·
>> The model I'm currently toying with involves running "model operations" locally on my Backbone models, then sending those requests to the server, which authe
by catshirt 13y ago
>> The model I'm currently toying with involves running "model operations" locally on my Backbone models, then sending those requests to the server, which authenticates and validates them, returning canonical model data as a result. This is important to me because I need to verify that the model actions are valid rather than simply allowing arbitrary writes from models.
if i understand correctly, this is exactly what i attempted with Brainy. all validation is run on the client (if they fail they don't send) and again on the server (if they fail they return an error response code). check out the `validate` documentation. [1]
>> I'm also looking at well known collections as queries, such that the client can define some, upload the fetch request to the server, and the server will use the underlying database to populate the collection results, subject to privacy and access.
again, correct me if i'm wrong, but i think this is baked into Brainy on top of Backbone's fetch. [2]
[1] http://brainy.io/#resources-validate http://brainy.io/#resources-validate
[2] http://brainy.io/#resources-fetch http://brainy.io/#resources-fetch
- CGamesPlay 13y agoConsider an "add user to thread" function. Only participating users can add other members. First, how would I do authentication/authorization with Brainy? Second, the easiest way to enforce the existing member relationship is to have a method that validates an "add user" function call and then performs the action. With a single "validate" method, you need to know the old values and the new values and compute the delta. Does Brainy support that? As far as collections, pretend a user can only see threads for which he is a member. Can that be enforced with Brainy? It could be if the queries were well-defined methods that produced query strings and were executed on the server. I ask about all this because I'm basically implementing it manually in my current project, and it would be neat to have something reusable at the end of these efforts.
- catshirt 13y agoi'm currently doing this with a session model. and i override my model save/fetch to validate the session before performing some operation. it's not packaged because i'm hesitant to include any client-specific code (yet) and i'm not sure it's any sort of secure. if you open an issue on the project i'll remember to respond with more detail.