Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

296
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda