The MJoin class provides a one-to-many join link for Editor. This can be useful in cases were an attribute can take multiple values at the same time - for example cumulative security access levels.

Typically the MJoin class should be used with a link table, but this is optional. Please note that if you don't use a link table you should be aware that on edit the linked rows are deleted and then reinserted, thus if any values should be retained they should also be submitted.

Please refer to the Editor Node documentation for further information https://editor.datatables.net/manual/node

Export

Hierarchy

  • default
    • Mjoin

Constructors

  • Creates an instance of Mjoin.

    Parameters

    • table: string

      Table name being joined to

    Returns Mjoin

Properties

SetType: typeof SetType = SetType

Methods

  • Get or field by name, or add a field instance.

    Returns

    Mjoin instance if adding a field, Field instance if getting a field.

    Parameters

    • nameOrField: string

      Field instance to add, or field name to get

    Returns any

  • Parameters

    Returns any

  • Get the fields assigned to this instance.

    Returns

    Array of fields

    Returns Field[]

  • Add one or more fields to the instance.

    Returns

    Self for chaining

    Parameters

    • Rest ...fields: Field[]

      Fields to add

    Returns Mjoin

  • Get the get flag for all fields in the Mjoin instance.

    Returns

    True if gettable, false otherwise.

    Returns boolean

  • Set the get flag for all fields in the Mjoin instance. When set to false no read operations will occur on the join tables.

    Returns

    Self for chaining

    Parameters

    • flag: boolean

      true to mark as readable, false otherwise

    Returns Mjoin

  • Add a left join condition to the Mjoin instance, allowing it to operate over multiple tables.

    In this form the method will take a function as the second parameter which is a Knex callback function allowing a complex join expression to be built.

    Returns

    Self for chaining

    Parameters

    • table: string

      Table name to do a join onto

    • condition: Function

    Returns Mjoin

  • Add a left join condition to the Mjoin instance, allowing it to operate over multiple tables.

    Returns

    Self for chaining

    Parameters

    • table: string

      Table name to do a join onto

    • field1: string

      Field from the parent table to use as the join link

    • operator: string

      Join condition (=, '<`, etc)

    • field2: string

      Field from the child table to use as the join link

    Returns Mjoin

  • Create a join link between two tables. The order of the fields does not matter, but each field must contain the table name as well as the field name.

    This method can be called a maximum of two times for an Mjoin instance:

    • First time, creates a link between the Editor host table and a join table
    • Second time creates the links required for a link table.

    Please refer to the Editor Mjoin documentation for further details: https://editor.datatables.net/manual/php

    Returns

    Self for chaining

    Parameters

    • field1: string

      Table and field name

    • field2: string

      Table and field name

    Returns Mjoin

  • Get the instance's configured name.

    The name of the Join is the JSON property key that is used when 'getting' the data, and the HTTP property key (in a JSON style) when 'setting' data. Typically the name of the db table will be used here, but this method allows that to be overridden.

    Returns

    Current name.

    Returns string

  • Set the instance's name

    Returns

    Self for chaining

    Parameters

    • name: string

      Name to set

    Returns Mjoin

  • Get the column name to order the data by

    Returns

    SQL column name

    Returns string

  • Specify the property that the data will be sorted by.

    Returns

    Self for chaining

    Parameters

    • order: string

      SQL column name to order the data by

    Returns Mjoin

  • Get the current set property for the field.

    Returns

    Set configuration

    Returns SetType

  • Set the field's set configuration.

    A field can be marked as read only using this option, to be set only during an create or edit action or to be set during both actions. This provides the ability to have fields that are only set when a new row is created (for example a "created" time stamp).

    Returns

    Self for chaining.

    Parameters

    • flag: boolean | SetType

      Set flag.

    Returns Field

  • Get join table name.

    Please note that this will also set the name used by the Join as well. This is for convenience as the JSON output / HTTP input will typically use the same name as the database name. If you want to set a custom name, the name method must be called after this one.

    Returns

    Join table name

    Returns string

  • Set column join name

    Returns

    Self for chaining

    Parameters

    • table: string

      Join table name

    Returns Mjoin

  • Set a validator for the array of data (not on a field basis)

    Parameters

    • fieldName: string

      Name of the field that any error should be shown against on the client-side

    • fn: IMjoinValidator

      Callback function for validation

    Returns Mjoin

  • Get the array of conditions applied to the method.

    Returns

    Knex where conditions.

    Returns any[]

  • Where condition to add to the query used to get data from the database. Note that this is applied to the child table.

    Returns

    Self for chaining.

    Parameters

    • cond: any

      Knex query condition

    Returns Mjoin

Generated using TypeDoc