Class Projections

java.lang.Object
com.datastax.astra.client.model.Projections

public class Projections extends Object
Encode the presence of a field in the result.
  • Method Details

    • include

      public static Projection[] include(String... field)
      Include a field in the result.
      Parameters:
      field - include field
      Returns:
      name to include
    • slice

      public static Projection slice(String field, Integer start, Integer end)
      Specifies the number of elements in an array to return in the query result.
       
       // Return the first two elements
       { $slice: 2 }
      
       // Return the last two elements
       { $slice: -2 }
      
       // Skip 4 elements (from 0th index), return the next 2
       { $slice: [4, 2] }
      
       // Skip backward 4 elements, return next 2 elements (forward)
       { $slice: [-4, 2] }
       
       
      Parameters:
      field - field name for slice
      start - start index of slice
      end - end index of slice
      Returns:
      a projection for the slide
    • exclude

      public static Projection[] exclude(String... field)
      Exclude a field in the result.
      Parameters:
      field - field name to exclude
      Returns:
      list of projection