datatables.net-editor-server
    Preparing search index...

    Class Mjoin

    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

    Mjoin

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    SetType: typeof SetType = SetType

    Methods

    • Get a field by name

      Parameters

      • name: string

        Field instance to add, or field name to get

      Returns Field

      The field - throws if not found

    • Add a field instance.

      Parameters

      • field: Field

        Field to add

      Returns this

      Self instance for chaining

    • Get the fields assigned to this instance.

      Returns Field[]

      Array of fields

    • Add one or more fields to the instance.

      Parameters

      • ...fields: Field[]

        Fields to add

      Returns Mjoin

      Self for chaining

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

      Returns boolean

      True if gettable, false otherwise.

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

      Parameters

      • flag: boolean

        true to mark as readable, false otherwise

      Returns Mjoin

      Self for chaining

    • 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.

      Parameters

      • table: string

        Table name to do a join onto

      • condition: Function

      Returns Mjoin

      Self for chaining

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

      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

      Self for chaining

    • 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

      Parameters

      • field1: string

        Table and field name

      • field2: string

        Table and field name

      Returns Mjoin

      Self for chaining

    • 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 string

      Current name.

    • Set the instance's name

      Parameters

      • name: string

        Name to set

      Returns Mjoin

      Self for chaining

    • Internal

      Get options for the fields in this join.

      Parameters

      • options: Record<string, Record<string, any>>

        Options object

      • db: Knex

        Database connection object

      • refresh: boolean

        Refresh indication flag

      Returns Promise<void>

    • Get the column name to order the data by

      Returns string

      SQL column name

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

      Parameters

      • order: string

        SQL column name to order the data by

      Returns Mjoin

      Self for chaining

    • Get the current set property for the field.

      Returns SetType

      Set configuration

    • 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).

      Parameters

      Returns Field

      Self for chaining.

    • 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 string

      Join table name

    • Set column join name

      Parameters

      • table: string

        Join table name

      Returns Mjoin

      Self for chaining

    • 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 this

    • Get the array of conditions applied to the method.

      Returns any[]

      Knex where conditions.

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

      Parameters

      • cond: any

        Knex query condition

      Returns Mjoin

      Self for chaining.