Class MongoDBSubStringFunction

java.lang.Object
com.kingsrook.qqq.backend.module.mongodb.fieldfunctions.MongoDBSubStringFunction
All Implemented Interfaces:
BackendFieldFunctionAdapterInterface, MongoDBFieldFunctionAdapterInterface, Serializable

public class MongoDBSubStringFunction extends Object implements MongoDBFieldFunctionAdapterInterface
MongoDB adapter for SubStringFunction. Generates {$substrCP: ["$field", fromIndex, length]}. MongoDB $substrCP is 0-based; QQQ SubStringFunction uses 1-based (like SQL). When no length is specified, uses Integer.MAX_VALUE as a sentinel.
See Also:
  • Constructor Details

    • MongoDBSubStringFunction

      public MongoDBSubStringFunction()
  • Method Details

    • getExpression

      public Object getExpression(String fieldReference, FieldFunction fieldFunction, Function<String,String> fieldNameToFieldReference)
      Description copied from interface: MongoDBFieldFunctionAdapterInterface
      Returns a MongoDB aggregation expression for the given field reference. The fieldReference is a "$"-prefixed field name (e.g., "$firstName").
      Specified by:
      getExpression in interface MongoDBFieldFunctionAdapterInterface
      Parameters:
      fieldReference - "$"-prefixed field name for the function's source field.
      fieldFunction - the function with arguments.
      fieldNameToFieldReference - resolves a QQQ field name to its "$"-prefixed MongoDB field reference (e.g., "timeZone" → "$time_zone"). Useful when the function expression needs to reference additional fields on the same document (e.g., a per-row timezone field).