jenkoian/lunchme — pull request #2 by athieriot (2013-03-02 00:34:35+00:00)
Title: Rating

Ok.

So I figure to have a nice example of rating with AngularJS.

I had to change a bit the API so Angular was happy and Mongodb as well:
- Angular need a single URL for every actions. I mean /venues/ and not venue + venues (This is not a bad practice)
- MongoDB don't want to update an object who contains an "_id" field. So I had to decorate the objects:
- OUT = _id become id so we can have it for further actions
- IN = id is removed so it will not be saved in the database

On the Angular side it's pretty nice. You manipulate your venues like any entity (new, $save, $update, get, etc... ) and EVERYTHING is updated. The HTML view and the API, so the database.

One caveat: The API call is made asynchronously, so if you uprate or downrate too fast... it feels all messed up :p
Just need to figure a way to wait a couple of seconds.

Also, basic design. Everything can be broken.

Tell me what you think !

Aurélien