Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface PropertyConverter

Describes a type that is able to convert an entity or embeddable property value to a MongoDB document field and back.

Example

The example below defines a PropertyConverter that converts an instance of a Point class to a string.

 class PointConverter implements PropertyConverter {

     convertToDocumentField(property: any): any {
         if(property instanceof Point) {
             return [property.x, property.y].join(",");
         }
     }

     convertToObjectProperty(field: any): any {
         if(typeof field === "string") {
             var parts = field.split(",");
             return new Point(parts[0], parts[1]);
        }
     }
 }

Hierarchy

  • PropertyConverter

Index

Methods

areEqual

  • areEqual(field1: any, field2: any): boolean
  • areEqual(field1: any, field2: any): boolean
  • Returns true if the document field values are equal; otherwise, returns false. This method is only called if both values are not null and the values are not strictly equal.

    Parameters

    • field1: any

      First document field value.

    • field2: any

      Other document field value.

    Returns boolean

  • Returns true if the document field values are equal; otherwise, returns false. This method is only called if both values are not null and the values are not strictly equal.

    Parameters

    • field1: any

      First document field value.

    • field2: any

      Other document field value.

    Returns boolean

convertToDocumentField

  • convertToDocumentField(property: any): any
  • convertToDocumentField(property: any): any
  • Converts an object property value to a document field value.

    Parameters

    • property: any

      The property value to convert.

    Returns any

  • Converts an object property value to a document field value.

    Parameters

    • property: any

      The property value to convert.

    Returns any

convertToObjectProperty

  • convertToObjectProperty(field: any): any
  • convertToObjectProperty(field: any): any
  • Converts a document field value to an object property value.

    Parameters

    • field: any

      The field value to convert.

    Returns any

  • Converts a document field value to an object property value.

    Parameters

    • field: any

      The field value to convert.

    Returns any

Generated using TypeDoc