Document
public class Document : Properties
A Couchbase Lite document. A document has key/value properties like a Dictionary; their API is defined by the superclass Properties. To learn how to work with properties, see that class’s documentation.
-
The document’s ID.
Declaration
Swift
public var documentID: String
-
The document’s owning database.
Declaration
Swift
public let database: Database
-
Is the document deleted?
Declaration
Swift
public var isDeleted: Bool
-
Checks whether the document exists in the database or not. If not, saving it will create it.
Declaration
Swift
public var exists: Bool
-
Sequence number of the document in the database. This indicates how recently the document has been changed: every time any document is updated, the database assigns it the next sequential sequence number. Thus, if a document’s
sequence
property changes that means it’s been changed (on-disk); and if one document’ssequence
is greater than another’s, that means it was changed more recently.Declaration
Swift
public var sequence: UInt64
-
The conflict resolver, if any, specific to this document. If nil, the database’s conflict resolver will be used.
Declaration
Swift
public var conflictResolver: ConflictResolver?
-
Saves property changes back to the database. If the document in the database has been updated since it was read by this CBLDocument, a conflict occurs, which will be resolved by invoking the conflict handler. This can happen if multiple application threads are writing to the database, or a pull replication is copying changes from a server.
Declaration
Swift
public func save() throws
-
Deletes this document. All properties are removed, and subsequent calls to -documentWithID: will return nil. Deletion adds a special
tombstone
revision to the database, as bookkeeping so that the change can be replicated to other databases. Thus, it does not free up all of the disk space occupied by the document. To delete a document entirely (but without the ability to replicate this), use -purge:.Declaration
Swift
public func delete() throws
-
Purges this document from the database. This is more drastic than deletion: it removes all traces of the document. The purge will NOT be replicated to other databases.
Declaration
Swift
public func purge() throws
-
Reverts unsaved changes made to the document’s properties.
Declaration
Swift
public func revert()
-
Equal to operator for comparing two Documents object.
Declaration
Swift
public static func == (doc1: Document, doc: Document) -> Bool