Hi, in my iOS app (CouchbaseLite 1.3) I sometimes want to create documents that will be discarded or not persisted. I tried using CBLModel.modelForNewDocumentInDatabase() since the method definition in the code says: /** Returns a new “untitled” CBLModel with a new unsaved document.
The document won’t be written to the database until -save is called. */
I noticed though that the documents it returns have an id field, and I can kill my app, re-start it, and then find those documents by ID in my database. How would I create a temporary document that will only get persisted when I call save()?
You can create a new CBLDocument, and even though it has an ID it doesn’t exist in the database yet. It won’t be persisted until you save it using putProperties:, update:, or by adding a new CBLRevision and saving that.
I can kill my app, re-start it, and then find those documents by ID in my database.
When a CBLDatabase is closed it saves any CBLModels that have unsaved changes, so that’s probably what you’re seeing. (On iOS this also happens when the app is suspended.)