Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

301
Visualizações
Multiple 'belongsTo' joins in a cube in Cube.js

There are three cubes that I need to create, namely, "Order", "OrderItem" and "Adjustment". Adjustments can belong to Order or OrderItem (not to both at the same time).

Order -> Adjustment is a one-to-many relationship and therefore Order has "hasMany" join with Adjustment.

OrderItem -> Adjustment is also a one-to-many relationship and so OrderItem has "hasMany" join with Adjustment.

Now, how do I model the Adjustment cube? Can it have two joins of the "belongsTo" kind like the following:

 cube('Adjustments', {
  sql: `SELECT * FROM "orders-parquet-${ENVIRONMENT}".order_adjustments`,

  joins: {
    Orders: {
      relationship: 'belongsTo',
      sql: `${Orders}.order_id = ${Adjustments}.order_id`,
    },
    OrderItems: {
      relationship: 'belongsTo',
      sql: `${OrderItems}.order_item_id = ${Adjustments}.order_item_id`,
    },
  },

Is this the proper way to model the cubes? I googled but could not find any example where two "belongsTo" joins were used in one cube.

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda