JavaScript Objection relation mapping

I am wondering if there is a way to solve my problem. I want implement this type of join SQL JOIN Records ON Accounts.id = Records.account_id OR Accounts.id = Records.from_account_id; with Objection Relation Mapping, but it doesn't work for me, need someting like that:

records: {
        relation: Model.HasManyRelation,
        modelClass: RecordModel,
        join: {
          from: getJoinRelationPath<AccountModel>(DatabaseTableName.ACCOUNTS, 'id'),
          to: 'records.accountId OR records.fromAccountId',
        }
      },




 records: {
          relation: Model.HasManyRelation,
          modelClass: Record,
          join: {
            from: 'accounts.id',
            to: 'records.account_id'
          }
        },
        recordsFrom: {
          relation: Model.HasManyRelation,
          modelClass: Record,
          join: {
            from: 'accounts.id',
            to: 'records.from_account_id'
          }
        }
      }

Found only this solution, but don't want to have separated fields

Upvotes: 0

Views: 53

Answers (0)

Related Questions