hey y'all wondering if theres a way to get the uni...
# help
d
hey y'all wondering if theres a way to get the union of types in these tables from the generated types. Have a call that gets these rooms, then gets the users that have the roomId as a key relation
Copy code
id,
slug,
params,
players:users(id, publicAddress, name)
n
Hello @drilkmops! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
d
might be easier to see with all the generated types
Copy code
players: {
  /**
   * Format: uuid
   * @description Note:
   * This is a Primary Key.<pk/>
   * This is a Foreign Key to `users.id`.<fk table='users' column='id'/>
   */
  player_id: string;
  /**
   * Format: uuid
   * @description Note:
   * This is a Primary Key.<pk/>
   * This is a Foreign Key to `rooms.id`.<fk table='rooms' column='id'/>
   */
  room_id: string;
};
rooms: {
  /**
   * Format: uuid
   * @description Note:
   * This is a Primary Key.<pk/>
   * @default extensions.uuid_generate_v4()
   */
  id: string;
  /**
   * Format: timestamp with time zone
   * @default now()
   */
  created_at?: string;
  /** Format: text */
  slug: string;
  /** Format: jsonb */
  params?: string;
  /** Format: uuid */
  created_by?: string;
};
users: {
  /**
   * Format: character varying
   * @description Note:
   * This is a Primary Key.<pk/>
   */
  publicAddress: string;
  /**
   * Format: timestamp with time zone
   * @default now()
   */
  created_at?: string;
  /** Format: character varying */
  nonce: string;
  /**
   * Format: uuid
   * @default extensions.uuid_generate_v4()
   */
  id?: string;
  /** Format: text */
  name?: string;
};
l
you can try doing a union type:
Copy code
ts
type MyUnionType = definitions["players"] & definitions["users"]
and passing that as a generic
n
Blaynem (2022-03-16)
l
not as satisfyingly robust as prisma but yeah
d
aight i can figure it out with that i think. other than that how do i make players an array? that extra
[]
doesnt work it doesn't look like
Copy code
type myUnionType = {
  players?: definitions["players"][]
} & definitions["rooms"]
ah, nvm im bad at reading errors. Thanks for the help!
n
Thread was archived by @drilkmops. Anyone can send a message to unarchive it.