Class CollectionExtensionsKt

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      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.
      final static <T extends DocumentModel> T getDocumentAs(Collection $self, String id, DeserializationStrategy<T> deserializer)
      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.
      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.
      final static Boolean delete(Collection $self, DocumentModel model, ConcurrencyControl concurrencyControl) Deletes a model's document from the collection.
      final static Unit purge(Collection $self, DocumentModel model) Purges a model's document from the collection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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.

      • 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, or null to 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.