How to reference to composite primary key

export const placedOrders = pgTable('placed_orders', {
  orderId: serial('order_id').primaryKey(),
  userId: integer('user_id').references(() => users.address),
  arenaId: integer('arena_id').notNull(),
  stockId: // ???
  qty: bigint({mode: "bigint"}).notNull(),
  side: orderSide().notNull(),
  type: orderType().notNull(),
  status: orderStatusEnum().notNull(),
  createdAt: timestamp('created_at').notNull(),
});

export const stocks = pgTable('stocks', {
  coinA: varchar({ length: 6 }).references(() => coins.symbol),
  coinB: varchar({ length: 6 }).references(() => coins.symbol),
}, t =>
  [
    primaryKey({ columns: [t.coinA, t.coinB] }),
  ],
);

export const coins = pgTable("coins", {
  symbol: varchar({ length: 6 }).primaryKey(),
  name: text().notNull(),
  decimals: smallint().notNull(),
})
Was this page helpful?