This is the basic schema type. All schema types should inherit from this class. For example:

class SchemaTypeCustom extends SchemaType {};

Query operators

To add a query operator, defines a method whose name is started with q$. For example:

SchemaTypeCustom.q$foo = function(value, query, data){
// ...
};

The value parameter is the value of specified field; the query parameter is the value passed to the query operator; the data parameter is the complete data.

The return value must be a boolean indicating whether the data passed.

Update operators

To add a update operator, defines a method whose name is started with u$. For example:

SchemaTypeCustom.u$foo = function(value, update, data){
// ...
};

The value parameter is the value of specified field; the update parameter is the value passed to the update operator; the data parameter is the complete data.

The return value will replace the original data.

Type Parameters

  • T

Hierarchy (View Summary)

Constructors

  • SchemaType constructor.

    Type Parameters

    • T

    Parameters

    • name: string = ''
    • Optionaloptions: { default?: T | () => T; required?: boolean }

    Returns default<T>

Properties

default: () => T
name: string = ''
options: { default?: T | () => T; required: boolean }
q$exists: (value: unknown, query: unknown, data?: unknown) => boolean

Type declaration

    • (value: unknown, query: unknown, data?: unknown): boolean
    • Checks the existance of data.

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

q$max: (value: unknown, query: unknown, data?: unknown) => boolean

Type declaration

    • (value: unknown, query: unknown, data?: unknown): boolean
    • Checks whether value is less than or equal to (i.e. <=) the query.

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

q$min: (value: unknown, query: unknown, data?: unknown) => boolean

Type declaration

    • (value: unknown, query: unknown, data?: unknown): boolean
    • Checks whether value is greater than or equal to (i.e. >=) the query.

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

Methods

  • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

    Parameters

    • Optionalvalue: unknown
    • Optionaldata: unknown

    Returns unknown

  • Compares data. This function is used when sorting.

    Parameters

    • a: unknown
    • b: unknown

    Returns number

  • Checks the equality of data.

    Parameters

    • value: T
    • query: unknown
    • Optionaldata: unknown

    Returns boolean

  • Parses data. This function is used when restoring data from database files.

    Parameters

    • value: unknown

    Returns any

  • Checks the existance of data.

    Parameters

    • value: unknown
    • query: unknown
    • Optionaldata: unknown

    Returns boolean

  • Checks whether value is greater than (i.e. >) the query.

    Parameters

    • value: unknown
    • query: unknown
    • Optionaldata: unknown

    Returns boolean

  • Checks whether value is greater than or equal to (i.e. >=) the query.

    Parameters

    • value: unknown
    • query: unknown
    • Optionaldata: unknown

    Returns boolean

  • Checks whether value is equal to one of elements in query.

    Parameters

    • value: unknown
    • query: unknown[]
    • Optionaldata: unknown

    Returns boolean

  • Checks whether value is less than (i.e. <) the query.

    Parameters

    • value: unknown
    • query: unknown
    • Optionaldata: unknown

    Returns boolean

  • Checks whether value is less than or equal to (i.e. <=) the query.

    Parameters

    • value: unknown
    • query: unknown
    • Optionaldata: unknown

    Returns boolean

  • Checks the equality of data. Returns true if the value doesn't match.

    Parameters

    • value: T
    • query: unknown
    • Optionaldata: unknown

    Returns boolean

  • Checks whether value is not equal to any elements in query.

    Parameters

    • value: unknown
    • query: unknown[]
    • Optionaldata: unknown

    Returns boolean

  • Renames a field.

    Parameters

    • value: unknown
    • update: string
    • data: unknown

    Returns void

  • Sets the value.

    Type Parameters

    • T

    Parameters

    • value: unknown
    • update: T
    • Optionaldata: unknown

    Returns T

  • Unsets the value.

    Type Parameters

    • T

    Parameters

    • value: T
    • update: boolean
    • Optionaldata: unknown

    Returns T

  • Validates data. This function is used by setters.

    Parameters

    • value: unknown
    • Optionaldata: unknown

    Returns unknown

  • Transforms value. This function is used when saving data to database files.

    Parameters

    • value: unknown
    • Optionaldata: unknown

    Returns any