Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Constructors

  • new Mjoin(table: string): Mjoin
  • Creates an instance of Mjoin.

    Parameters

    • table: string

      Table name being joined to

    Returns Mjoin

Properties

SetType: typeof SetType = SetType

Methods

  • field(nameOrField: string): any
  • field(nameOrField: Field): any
  • Get or field by name, or add a field instance.

    Parameters

    • nameOrField: string

      Field instance to add, or field name to get

    Returns any

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

  • Parameters

    Returns any

  • Get the fields assigned to this instance.

    Returns Field[]

    Array of fields

  • Add one or more fields to the instance.

    Parameters

    • Rest ...fields: Field[]

      Fields to add

    Returns Mjoin

    Self for chaining

  • get(): boolean
  • get(flag: boolean): Mjoin
  • 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

  • link(field1: string, field2: string): 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

    Parameters

    • field1: string

      Table and field name

    • field2: string

      Table and field name

    Returns Mjoin

    Self for chaining

  • name(): string
  • name(name: string): 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 string

    Current name.

  • Set the instance's name

    Parameters

    • name: string

      Name to set

    Returns Mjoin

    Self for chaining

  • order(): string
  • order(order: string): Mjoin
  • 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

  • set(): SetType
  • set(flag: boolean | SetType): Field
  • 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

    • flag: boolean | SetType

      Set flag.

    Returns Field

    Self for chaining.

  • table(): string
  • table(table: string): Mjoin
  • 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

  • validator(fieldName: string, fn: IMjoinValidator): 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

  • where(): any[]
  • where(cond: any): Mjoin
  • 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.

Generated using TypeDoc