Select Entry in db with relational tables

Hi, i'm using this request to get a store corresponding to the cuid, an di want to get also all his related categories from store_categories tabe
    const result = await db.select()
    .from(stores)
    .where(eq(stores.cuid_store, cuid_store))
    .innerJoin(stores_categories, eq(stores.id_store, stores_categories.id_store))


but it returns multiple times the store object for eact category.
i would like to have instead

stores:{
      id_store: 11,
      cuid_store: 'rjkghtj06ajbai7',
      id_currency: 1,
      name: 'OobaOoba',
      baseline: 'Les deserts du futur',
      realtime_position: null,
      last_position_updated: 2023-09-21T13:54:26.000Z,
      profile_picture: 'public/upload/stores/rjkghtj06ajbai7/OobaOoba_cover.jpg',
      featured_label: 'Populaire',
      siret: '81359940400023',
      ape: '5610C',
      wrapping_enabled: false,
      wrapping_price: '0',
      cutleries_enabled: false,
      cutleries_price: '0',
      date_add: null,
      date_updated: null
},
stores_categories[6,12,4]


where stores_categories are the categrories ids
image.png
Was this page helpful?