Closed kforkarim closed 11 years ago
I am just curious as per the document as if it leads to the _changes feed, it should reflect couchDocumentChanged Protocol
I don't really understand this sentence.
-couchDocumentChanged: is a method that can be implemented by the model object assigned to a CouchDocument's model property. Normally this is a CouchModel object, and CouchModel implements this property and takes care of updating itself. The only time you'd need to use this method yourself is if you are bypassing CouchModel and setting up your own objects as models on CouchDocuments. Is that what you're doing?
I have set the property of tracker as "YES" [rbc_Database setTracksChanges:YES];
If you're using TouchDB you shouldn't set this. This property is for use with remote databases.
However when I try to update the document from the portal, I don't get any notification via tha protocol.
What is the "portal"?
I have also created an instance of CocoaDocument and triggering the document list
I don't know what this means. What is "CocoaDocument"?
snej, I am uploading the code here maybe I could reference from that.
(void)startCouchDB {
//Initialize Server NSURL* serverURL = [NSURL URLWithString: SERVER_NAME]; CouchServer *server = [[CouchServer alloc] initWithURL: serverURL]; self.rbc_Database = [server databaseNamed: DATABASE_NAME];
//Set track changes [rbc_Database setTracksChanges:YES];
//Initialize Rest Operation RESTOperation* op = [rbc_Database GET]; if (![op wait]) //[self failed: op.error] NSLog(@"%@",[op.error description]);
else {
NSLog(@"%@",op.description);
//Set the database bool to YES
rbc_IsDatabaseReady = YES;
}
//Read a document (get the id from the "Document Changed" and then place it in the documentWithID to surpress) self.rbc_Doc = [rbc_Database documentWithID: @"b7610a21eee2ce00123c6c147c000abc"]; NSDictionary* contents = rbc_Doc.properties; NSLog(@"%@",[contents description]); }
(void) changeTrackerReceivedChange: (NSDictionary*)change {
NSLog(@"%@",[change description]); }
(void) couchDocumentChanged:(CouchDocument *)doc {
NSLog(@"%@",[doc currentRevisionID]); }
CouchDocument is a class in CocoaCouch framework which invoke the method "couchDocumentChanged".
Portal here is as following: "http://127.0.0.1:5984/_utils/" where I can choose the database, and goto a particular document and update an entity.
I am currently using couchDB on a local machine not on the phone.
So reflecting back to your definition: "-couchDocumentChanged: is a method that can be implemented by the model object assigned to a CouchDocument's model property. Normally this is a CouchModel object, and CouchModel implements this property and takes care of updating itself. The only time you'd need to use this method yourself is if you are bypassing CouchModel and setting up your own objects as models on CouchDocuments. Is that what you're doing?"
"Actually that is not what I am doing at this point. I was in impression that at any given time if any document does gets updated on a remote couchdb, this method gets invoked", but I guess this doesn't seams to be the case at all?
I am new to this framework and still trying to understand how overall this framework works, hence apologies if anything look silly here.
I was in impression that at any given time if any document does gets updated on a remote couchdb, this method gets invoked
It does. But only one the object that's the current value of the document's .modelObject property. The documentation for the method explicitly says that.
If you want some arbitrary other object to find out about changes to the document, you should use NSNotificationCenter to observe the kCouchDocumentChangeNotification
.
I must say you are genius. Thanks ALOT! :)
Hello CouchCocoa Community. Currently I am using CouchCocoa Framework in my application with local database instance, and hence I am trying to make an update from the portal of the document. I am just curious as per the document as if it leads to the _changes feed, it should reflect couchDocumentChanged Protocol. I have set the property of tracker as "YES" [rbc_Database setTracksChanges:YES];
However when I try to update the document from the portal, I don't get any notification via tha protocol. Is there anything that I am missing? I have also created an instance of CocoaDocument and triggering the document list, just incase if required.
Any help in such situation will be really appreciated.
Thanks