com.holonplatform.datastore.mongo.core.context

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

- Type Parameters:
    `S` - Concrete ClientSession type
  All Superinterfaces:
    com.holonplatform.core.ExpressionResolver.ExpressionResolverHandler, com.holonplatform.core.ExpressionResolver.ExpressionResolverProvider, com.holonplatform.core.ExpressionResolver.ExpressionResolverSupport, com.holonplatform.core.ExpressionResolver.ResolutionContext, MongoContext<S>, MongoResolutionContext<S>

      public interface MongoDocumentContext<S extends com.mongodb.session.ClientSession>
      extends MongoResolutionContext<S>

  A `MongoResolutionContext` which is bound to a document resolution operation.
  Since:
    5.2.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ID_FIELD_NAME` Default MongoDB document id field name

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <S extends com.mongodb.session.ClientSession> MongoDocumentContext<S>` | `create(MongoContext<S> context, com.holonplatform.core.property.PropertySet<?> propertySet)` Create a new `MongoDocumentContext`.
    `static <S extends com.mongodb.session.ClientSession> MongoDocumentContext<S>` | `createForUpdate(MongoContext<S> context, com.holonplatform.core.property.PropertySet<?> propertySet)` Create a new `MongoDocumentContext` for an update type operation.
    `Optional<com.holonplatform.core.Path<?>>` | `getDocumentIdPath()` Get the `Path` which acts as document id, if available.
    `Optional<com.holonplatform.core.property.Property<?>>` | `getDocumentIdProperty()` Get the `Property` which acts as document id, if available.
    `<P extends com.holonplatform.core.property.Property<?>> com.holonplatform.core.property.PropertySet<P>` | `getPropertySet()` Get the `PropertySet` to which the document resolution is bound.
    `static Optional<MongoDocumentContext<?>>` | `isDocumentContext(com.holonplatform.core.ExpressionResolver.ResolutionContext context)` Checks if given resolution context is a `MongoDocumentContext` type.
    `Optional<com.holonplatform.core.Path<?>>` | `isDocumentIdPath(com.holonplatform.core.Path<?> path)` Checks if given path matches the document id path, if available.
    `default boolean` | `isDocumentIdProperty(com.holonplatform.core.property.Property<?> property)` Checks if given property is the document id property.

    - ### Methods inherited from interface com.holonplatform.datastore.mongo.core.context.MongoResolutionContext

      `childContext, childContextForUpdate, childContextForUpdate, create, createForUpdate, createForUpdate, documentContext, documentContext, getAlias, getExpression, getExpressionAliasProvider, getNextProjectionFieldName, getOrCreateAlias, getParent, getQueryOperationType, getUpdatePath, isForUpdate, isMongoResolutionContext, maybeAliasName, resolve, resolveOrFail, setQueryOperationType`

    - ### Methods inherited from interface com.holonplatform.datastore.mongo.core.context.MongoContext

      `getClientSession, getDatabaseCodecRegistry, getDefaultEnumCodecStrategy, getDefaultReadConcern, getDefaultReadPreference, getDefaultWriteConcern, getDocumentIdResolver, toJson, toJson, toJson, trace, trace, trace, trace`

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

      `resolve`

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

      `getExpressionResolvers`

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

      `addExpressionResolver, addExpressionResolvers, removeExpressionResolver`

- - ### Field Detail

    - #### ID_FIELD_NAME

          static final String ID_FIELD_NAME

      Default MongoDB document id field name
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getPropertySet

          <P extends com.holonplatform.core.property.Property<?>> com.holonplatform.core.property.PropertySet<P> getPropertySet()

      Get the `PropertySet` to which the document resolution is bound.
      Type Parameters:
        `P` - Property type
      Returns:
        The document `PropertySet`

    - #### getDocumentIdPath

          Optional<com.holonplatform.core.Path<?>> getDocumentIdPath()

      Get the `Path` which acts as document id, if available.
      Returns:
        Optional document id path

    - #### getDocumentIdProperty

          Optional<com.holonplatform.core.property.Property<?>> getDocumentIdProperty()

      Get the `Property` which acts as document id, if available.
      Returns:
        Optional document id property

    - #### isDocumentIdProperty

          default boolean isDocumentIdProperty(com.holonplatform.core.property.Property<?> property)

      Checks if given property is the document id property.
      Parameters:
        `property` - The property to check
      Returns:
        `true` if the property acts as document id property

    - #### isDocumentIdPath

          Optional<com.holonplatform.core.Path<?>> isDocumentIdPath(com.holonplatform.core.Path<?> path)

      Checks if given path matches the document id path, if available.
      Parameters:
        `path` - The path to check
      Returns:
        If a document id path is available and matches the given path, returns the actual document id path

    - #### isDocumentContext

          static Optional<MongoDocumentContext<?>> isDocumentContext(com.holonplatform.core.ExpressionResolver.ResolutionContext context)

      Checks if given resolution context is a `MongoDocumentContext` type.
      Parameters:
        `context` - The context to check
      Returns:
        If the given context is a `MongoDocumentContext`, returns the context itself as a `MongoDocumentContext` type. Otherwise an empty Optional is returned.

    - #### create

          static <S extends com.mongodb.session.ClientSession> MongoDocumentContext<S> create(MongoContext<S> context,
                                                                                              com.holonplatform.core.property.PropertySet<?> propertySet)

      Create a new `MongoDocumentContext`.
      Type Parameters:
        `S` - Concrete client session type
      Parameters:
        `context` - Mongo context (not null)
        `propertySet` - The `PropertySet` to which the document is bound (not null)
      Returns:
        A new `MongoDocumentContext` instance

    - #### createForUpdate

          static <S extends com.mongodb.session.ClientSession> MongoDocumentContext<S> createForUpdate(MongoContext<S> context,
                                                                                                       com.holonplatform.core.property.PropertySet<?> propertySet)

      Create a new `MongoDocumentContext` for an update type operation.
      Type Parameters:
        `S` - Concrete client session type
      Parameters:
        `context` - Mongo context (not null)
        `propertySet` - The `PropertySet` to which the document is bound (not null)
      Returns:
        A new `MongoDocumentContext` instance

Copyright © 2019 The Holon Platform. All rights reserved.