Package com.couchbase.lite
Class CollectionExtensionsKt
-
- All Implemented Interfaces:
public final class CollectionExtensionsKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends DocumentModel> TgetDocumentAs(Collection $self, String id)Gets an existing document with the given ID, and uses Kotlin Serialization to create an instance of class T from it. final static <T extends DocumentModel> TgetDocumentAs(Collection $self, String id, DeserializationStrategy<T> deserializer)final static <T extends DocumentModel> Booleansave(Collection $self, T model, String docID, Function2<T, T, Boolean> conflictHandler)Saves a DocumentModel instance as a document in the collection. final static <T extends DocumentModel> Booleansave(Collection $self, T model, SerializationStrategy<T> serializer, DeserializationStrategy<T> deserializer, String docID, Function2<T, T, Boolean> conflictHandler)Saves a DocumentModel instance as a document in the collection, explicitly passing the serialization strategy. final static Booleandelete(Collection $self, DocumentModel model, ConcurrencyControl concurrencyControl)Deletes a model's document from the collection. final static Unitpurge(Collection $self, DocumentModel model)Purges a model's document from the collection. -
-
Method Detail
-
getDocumentAs
final static <T extends DocumentModel> T getDocumentAs(Collection $self, String id)
Gets an existing document with the given ID, and uses Kotlin Serialization to create an instance of class T from it. T must implement DocumentModel. If a document with the given ID doesn't exist in the collection, returns null.
-
getDocumentAs
final static <T extends DocumentModel> T getDocumentAs(Collection $self, String id, DeserializationStrategy<T> deserializer)
-
save
final static <T extends DocumentModel> Boolean save(Collection $self, T model, String docID, Function2<T, T, Boolean> conflictHandler)
Saves a DocumentModel instance as a document in the collection. After a successful save, its DocumentModel.documentMeta property is updated to the current state.
- Parameters:
model- The DocumentModel instance to save.docID- The document ID to save a new unsaved model as, ornullto generate a unique ID.conflictHandler- A callback to resolve conflicts between the model and a more recently saved document revision.- Returns:
True on success, false on an unresolved conflict.
-
save
final static <T extends DocumentModel> Boolean save(Collection $self, T model, SerializationStrategy<T> serializer, DeserializationStrategy<T> deserializer, String docID, Function2<T, T, Boolean> conflictHandler)
Saves a DocumentModel instance as a document in the collection, explicitly passing the serialization strategy. (This overload is rarely needed.)
-
delete
final static Boolean delete(Collection $self, DocumentModel model, ConcurrencyControl concurrencyControl)
Deletes a model's document from the collection.
-
purge
final static Unit purge(Collection $self, DocumentModel model)
Purges a model's document from the collection.
-
-
-
-