Возражение js отношение присоединяется к дополнительному свойству - PullRequest
0 голосов
/ 14 апреля 2020

У меня есть следующие структуры таблиц:

Счет-фактура (ID, total_amount, change_amount, tendered_amount, qty, et c ..) Продукты (ID, имя, описание и др. c ..) Цена (product_id, price, current_price) Invoice_products (invoice_id, product_id, price_id, qty)

Я пытаюсь определить отношениеMappings для таблицы продуктов:

 static get relationMappings() {
    const Products = require('./products.model')();
    return {
      products: {
        relation: Model.ManyToManyRelation,
        modelClass: Products,
        join: {
          from: 'invoice.id',
          through: {
            from: 'invoice_items.invoice_id',
            to: 'invoice_items.product_id',
            extra: ['qty'],  // How do I add relation to price here using the product_id?
          },
          to: 'products.id',
        },
      },
    }
}

Возможно ли связать таблицу цен с дополнительной собственностью?

...