I want to sync the Core Data on iPhone with MongoDB on Sinatra server.
When the iPhone gets a message from the Node.js chat server, the message contains the sender's BSON ObjectId (a string). For the iPhone to store this message, I find the user with that same Id in Core Data. I want to be able to do something like objectWithID
. In other words, I want to set the NSManagedObjectIDs to be the same as the MongoDB BSON ObjectIds. The other thing I would check is if there are no users with the sender's id in the managedObjectContext, I will fetch him from the persistentStore, and if he's not there, I'll create him. This is a lot to do just to maintain the relationship between Message and Sender. Maybe I should just store the sender attribute of the Message object as his BSON ObjectId as a string instead of as a User NSManagedObject.
What do you recommend? Should I just use MongoDB on the iPhone too? I just realized there's an Objective-C driver for it. But I was just starting to get the hang of Core Data, and it has cool things (like undo support) that I might want to use... Right now, I'm just using it for simple fetching & persistent storage, so I could replace it. But I plan to implement undo support in the future, just because I think that's good usability. I prefer the option to undo than having to answer a confirmation pop-up, e.g., I like how GMail lets you undo a send or undo a deletion of messages, etc.
Thanks!
Matt