DittoCollection
@objc
public class DittoCollection : NSObject
A reference to a collection in a DittoStore
.
-
The name of the collection.
Declaration
Swift
@objc public let name: String
-
Inserts a new document into the collection and returns its assigned ID.
Throws
DittoKitError
.Precondition
The document content to insert must conform toCodable
.Declaration
Swift
@discardableResult public func insert<T>(_ content: T, isDefault: Bool = false) throws -> String where T : Decodable, T : Encodable
Parameters
content
The new document to insert.
isDefault
Represents whether or not the data being inserted should be treated as default data or not.
Return Value
The ID of the inserted document.
-
Inserts a new document into the collection and returns its assigned ID.
Throws
DittoKitError
.Declaration
Swift
@discardableResult public func insert(_ content: [String : Any?], isDefault: Bool = false) throws -> String
Parameters
content
The new document to insert.
isDefault
Represents whether or not the data being inserted should be treated as default data or not.
Return Value
The ID of the inserted document.
-
Generates a
DittoPendingIDSpecificOperation
with the provided document ID that can be used to find the document at a point in time or you can chain a call toobserve
,observeLocal
, orsubscribe
if you want to get updates about the document over time. It can also be used to update, remove or evict the document.Throws
DittoKitError
.Declaration
Swift
@objc public func findByID(_ _id: String) throws -> DittoPendingIDSpecificOperation
Parameters
_id
The _id of the document.
Return Value
A
DittoPendingIDSpecificOperation
that you can chain function calls to either get the document immediately or get updates about it over time. -
Generates a
DittoPendingCursorOperation
with the provided query that can be used to find the documents matching the query at a point in time or you can chain a call toobserve
,observeLocal
, orsubscribe
if you want to get updates about documents matching the query as they occur. It can also be used to update, remove, or evict documents.Throws
DittoKitError
.Declaration
Swift
@objc public func find(_ query: String) throws -> DittoPendingCursorOperation
Parameters
query
The query to run against the collection.
Return Value
A
DittoPendingCursorOperation
that you can use to chain further query-related function calls. -
Generates a
DittoPendingCursorOperation
that can be used to find all documents in the collection at a point in time or you can chain a call toobserve
,observeLocal
, orsubscribe
if you want to get updates about documents in the collection over time. It can also be used to update, remove or evict documents.Throws
DittoKitError
Declaration
Swift
@objc public func findAll() throws -> DittoPendingCursorOperation
Return Value
A
DittoPendingCursorOperation
that you can use to chain further query-related function calls.