Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Destroy deleted models

$
0
0
Yes I am using can.Model, I have a standard restful API with some nested models. This is quite hard to fiddle, since it involves at least 2 clients and a server. Either client can operate as a standalone client, accessing the API in a normal way. However, for cooperation the server has some observers that broadcast any changes to all clients that are teamed up.

Example:
Client A, Client B and a Server

can.Model "Album"
      attributes: 
            photos: "Photo.models"

Scenario 1: create/update album
  • Client A creates/updates Album#x
  • Server creates db record
  • Server broadcasts 'created/updated Album#x'  to Client B
  • Client B retrieves Album#x and displays it

Scenario 2: delete photo
  • Client A deletes Photo#y from Album#x
  • Server destroys db record for Photo#y
  • Server broadcasts 'deleted Photo#y'  to Client B
  • Now, if Client B now calls destroy on Photo#y it gives a 404 error on the server. So instead I fetch Album#x as a whole ( I include a reference to the parent of Photo#y in the broadcast message) and this works well.

I hope this is clear. I am looking for a destroy method without the server call.

Thanks,
Michel

Viewing all articles
Browse latest Browse all 3491

Trending Articles