How to use the objection.HasManyRelation function in objection

To help you get started, we’ve selected a few objection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Vincit / objection-rest / tests / utils.js View on Github external
from: 'Person.pid',
        to: 'Person.id'
      }
    },

    children: {
      relation: objection.HasManyRelation,
      modelClass: Person,
      join: {
        from: 'Person.id',
        to: 'Person.pid'
      }
    },

    pets: {
      relation: objection.HasManyRelation,
      modelClass: Animal,
      join: {
        from: 'Person.id',
        to: 'Animal.ownerId'
      }
    },

    movies: {
      relation: objection.ManyToManyRelation,
      modelClass: Movie,
      join: {
        from: 'Person.id',
        through: {
          from: 'Person_Movie.actorId',
          to: 'Person_Movie.movieId'
        },
github Vincit / objection-find / tests / utils.js View on Github external
Person.prototype.fullName = function() {
    return this.firstName + ' ' + this.lastName;
  };

  Person.relationMappings = {
    parent: {
      relation: objection.BelongsToOneRelation,
      modelClass: Person,
      join: {
        from: 'Person.pid',
        to: 'Person.id'
      }
    },

    pets: {
      relation: objection.HasManyRelation,
      modelClass: Animal,
      join: {
        from: 'Person.id',
        to: 'Animal.ownerId'
      }
    },

    movies: {
      relation: objection.ManyToManyRelation,
      modelClass: Movie,
      join: {
        from: 'Person.id',
        through: {
          from: 'Person_Movie.actorId',
          to: 'Person_Movie.movieId'
        },
github tandg-digital / objection-filter / test / utils.js View on Github external
static get relationMappings() {
      return {
        parent: {
          relation: objection.BelongsToOneRelation,
          modelClass: Person,
          join: {
            from: 'Person.pid',
            to: 'Person.id'
          }
        },

        pets: {
          relation: objection.HasManyRelation,
          modelClass: Animal,
          join: {
            from: 'Person.id',
            to: 'Animal.ownerId'
          }
        },

        movies: {
          relation: objection.ManyToManyRelation,
          modelClass: Movie,
          join: {
            from: 'Person.id',
            through: {
              from: 'Person_Movie.actorId',
              to: 'Person_Movie.movieId'
            },
github Vincit / objection-rest / tests / utils.js View on Github external
Person.prototype.fullName = function () {
    return this.firstName + ' ' + this.lastName;
  };

  Person.relationMappings = {
    parent: {
      relation: objection.BelongsToOneRelation,
      modelClass: Person,
      join: {
        from: 'Person.pid',
        to: 'Person.id'
      }
    },

    children: {
      relation: objection.HasManyRelation,
      modelClass: Person,
      join: {
        from: 'Person.id',
        to: 'Person.pid'
      }
    },

    pets: {
      relation: objection.HasManyRelation,
      modelClass: Animal,
      join: {
        from: 'Person.id',
        to: 'Animal.ownerId'
      }
    },