com.holonplatform.datastore.mongo.core.context

## Interface MongoContext<S extends com.mongodb.session.ClientSession>

- Type Parameters:
    `S` - Concrete ClientSession type
  All Superinterfaces:
    com.holonplatform.core.ExpressionResolver.ExpressionResolverProvider
  All Known Subinterfaces:
    AsyncMongoDatastoreCommodityContext, MongoDatastoreCommodityContext<MongoDatabase,S>, MongoDocumentContext<S>, MongoOperationContext<MongoDatabase,S>, MongoResolutionContext<S>, SyncMongoDatastoreCommodityContext

      public interface MongoContext<S extends com.mongodb.session.ClientSession>
      extends com.holonplatform.core.ExpressionResolver.ExpressionResolverProvider

  MongoDB Datastore base context.
  Since:
    5.2.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Optional<S>` | `getClientSession()` Get the current client session, if available.
    `org.bson.codecs.configuration.CodecRegistry` | `getDatabaseCodecRegistry()` Get the `CodecRegistry` bound to the current database.
    `EnumCodecStrategy` | `getDefaultEnumCodecStrategy()` Get the default `EnumCodecStrategy`.
    `Optional<com.mongodb.ReadConcern>` | `getDefaultReadConcern()` Get the default `ReadConcern` to declare the read operations isolation level.
    `Optional<com.mongodb.ReadPreference>` | `getDefaultReadPreference()` Get the default `ReadPreference` for query or data read operations.
    `Optional<com.mongodb.WriteConcern>` | `getDefaultWriteConcern()` Get the default `WriteConcern` to use with write operations.
    `DocumentIdResolver` | `getDocumentIdResolver()` Get the `DocumentIdResolver` of this context.
    `default String` | `toJson(org.bson.conversions.Bson bson)` Serialize given `Bson` value to JSON using the database codec registry.
    `default String` | `toJson(org.bson.Document document)` Serialize given document to JSON using the database codec registry.
    `default String` | `toJson(List<org.bson.Document> documents)` Serialize given documents to JSON using the database codec registry.
    `default void` | `trace(String title, org.bson.Document document)` Trace given JSON Document.
    `default void` | `trace(String title, List<org.bson.Document> documents)` Trace given JSON Documents.
    `default void` | `trace(String title, String json)` Trace given JSON expression.
    `void` | `trace(String title, Supplier<String> json)` Trace given JSON expression.

    - ### Methods inherited from interface com.holonplatform.core.ExpressionResolver.ExpressionResolverProvider

      `getExpressionResolvers`

- - ### Method Detail

    - #### getClientSession

          Optional<S> getClientSession()

      Get the current client session, if available.
      Returns:
        Optional client session

    - #### getDocumentIdResolver

          DocumentIdResolver getDocumentIdResolver()

      Get the `DocumentIdResolver` of this context.
      Returns:
        the `DocumentIdResolver`

    - #### getDatabaseCodecRegistry

          org.bson.codecs.configuration.CodecRegistry getDatabaseCodecRegistry()

      Get the `CodecRegistry` bound to the current database.
      Returns:
        Database `CodecRegistry`

    - #### getDefaultEnumCodecStrategy

          EnumCodecStrategy getDefaultEnumCodecStrategy()

      Get the default `EnumCodecStrategy`.
      Returns:
        the default `EnumCodecStrategy`s

    - #### getDefaultReadPreference

          Optional<com.mongodb.ReadPreference> getDefaultReadPreference()

      Get the default `ReadPreference` for query or data read operations.
      Returns:
        Optional default `ReadPreference`

    - #### getDefaultReadConcern

          Optional<com.mongodb.ReadConcern> getDefaultReadConcern()

      Get the default `ReadConcern` to declare the read operations isolation level.
      Returns:
        Optional the default `ReadConcern`

    - #### getDefaultWriteConcern

          Optional<com.mongodb.WriteConcern> getDefaultWriteConcern()

      Get the default `WriteConcern` to use with write operations.
      Returns:
        Optional default `WriteConcern`

    - #### toJson

          default String toJson(org.bson.Document document)

      Serialize given document to JSON using the database codec registry.
      Parameters:
        `document` - The document to serialize
      Returns:
        Serialized document

    - #### toJson

          default String toJson(List<org.bson.Document> documents)

      Serialize given documents to JSON using the database codec registry.
      Parameters:
        `documents` - The documents to serialize
      Returns:
        Serialized documents

    - #### toJson

          default String toJson(org.bson.conversions.Bson bson)

      Serialize given `Bson` value to JSON using the database codec registry.
      Parameters:
        `bson` - The Bson value to serialize
      Returns:
        Serialized Bson document

    - #### trace

          void trace(String title,
                     Supplier<String> json)

      Trace given JSON expression.

      If tracing is enabled, the JSON expression is logged using the `INFO` level, otherwise it is logged using the `DEBUG` level.

      Parameters:
        `title` - Optional title
        `json` - JSON to trace

    - #### trace

          default void trace(String title,
                             String json)

      Trace given JSON expression.

      If tracing is enabled, the JSON expression is logged using the `INFO` level, otherwise it is logged using the `DEBUG` level.

      Parameters:
        `title` - Optional title
        `json` - JSON to trace

    - #### trace

          default void trace(String title,
                             org.bson.Document document)

      Trace given JSON Document.

      If tracing is enabled, the JSON expression is logged using the `INFO` level, otherwise it is logged using the `DEBUG` level.

      Parameters:
        `title` - Optional title
        `document` - Document to trace

    - #### trace

          default void trace(String title,
                             List<org.bson.Document> documents)

      Trace given JSON Documents.

      If tracing is enabled, the JSON expression is logged using the `INFO` level, otherwise it is logged using the `DEBUG` level.

      Parameters:
        `title` - Optional title
        `documents` - Documents to trace

Copyright © 2019 The Holon Platform. All rights reserved.