Mixin HasMany

    View code

    One-to-many association

    In the API reference below, replace with the actual name of your association, e.g. for User.hasMany(Project) the getter will be user.getProjects().


    View code

    Get everything currently associated with this, using an optional where clause.

    Params:


    setAssociations([newAssociations], [options]) -> Promise

    Set the associated models by passing an array of persisted instances or their primary keys. Everything that is not in the passed array will be un-associated

    Params:

    NameTypeDescription
    [newAssociations]Array.<Instance | String | Number>An array of persisted instances or primary key of instances to associate with this. Pass null or to remove all associations.
    [options]ObjectOptions passed to target.findAll and update.
    [options.validate]ObjectRun validation for the join model

    addAssociations([newAssociations], [options]) -> Promise

    View code

    Associate several persisted instances with this.

    NameTypeDescription
    [newAssociations]Array.<Instance | String | Number>An array of persisted instances or primary key of instances to associate with this.
    [options]ObjectOptions passed to target.update.
    [options.validate]ObjectRun validation for the join model.

    View code

    Associate a persisted instance with this.

    Params:


    createAssociation([values], [options]) -> Promise

    Create a new instance of the associated model and associate it with this.

    Params:

    NameTypeDescription
    [values]Object
    [options]ObjectOptions passed to target.create.

    removeAssociation([oldAssociated], [options]) -> Promise

    View code

    Un-associate the instance.

    Params:

    NameTypeDescription
    [oldAssociated]Instance | String | NumberCan be an Instance or its primary key
    [options]ObjectOptions passed to target.update

    View code

    Params:


    hasAssociation([instance], [options]) -> Promise

    Check if an instance is associated with this.

    Params:

    NameTypeDescription
    [instance]Instance | String | NumberCan be an Instance or its primary key
    [options]ObjectOptions passed to getAssociations

    hasAssociations([instances], [options]) -> Promise

    View code

    Check if all instances are associated with this.

    Params:

    NameTypeDescription
    [instances]Array.<Instance | String | Number>Can be an array of instances or their primary keys
    [options]ObjectOptions passed to getAssociations

    View code

    Count everything currently associated with this, using an optional where clause.

    Params:


    This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on , open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see JSDoc and