$field static method

String $field(
  1. String field
)

Creates a field reference for use in MongoDB aggregation expressions.

This method prefixes a field name with '$' to create a field path expression that can be used in aggregation pipelines to reference document fields.

field The name of the field to reference

Example:

var fieldRef = DQ.$field('name'); // Returns: '$name'

// Usage in aggregation:
var projection = DQ.project({
  'upperName': {'\$toUpper': DQ.$field('name')}
});

Implementation

static String $field(String field) {
  return "\$$field";
}