Discussion:
Throw away all unsaved CBLModels in one go
Brendan Duddridge
2018-05-23 04:19:43 UTC
Permalink
Hi,

Is it possible to throw away all CBLModels that have been created? I
created them in a loop, but don't want to save them if the user clicks the
Cancel button.

So I don't want subsequent saveAllModels calls to save any of the objects I
want to throw out.

I know there's an unsavedModels function. Do I have to manually loop
through all of those and delete them all? If so, do I then save after that?
Will that create revisions or just silently forget about them?

Thanks!

Brendan
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchbase+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/087a8e04-3527-4904-a1bd-4401356a6937%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brendan Duddridge
2018-05-23 04:30:59 UTC
Permalink
To answer my own question, this seemed to have worked:


NSArray *unsavedModels = self.databaseDocument.couchDatabase.unsavedModels;

for (CBLModel *model in unsavedModels) {

[model revertChanges];

}
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchbase+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/90f75812-3b47-424b-bda4-5f19f395c7d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...