john093e
john093e
Explore posts from servers
TTCTheo's Typesafe Cult
Created by john093e on 5/15/2024 in #questions
uploadthing server SDK inside tRPC route (monorepo)
Hello everyone 🙂 I'm using the "create-t3-turbo" template and uploadthing, everything works well BUUUUUUUT... I trigger sometimes from the tRPC api route the uploadthing SDK (UTApi) Adding the uploadthing package inside the "package/api/package.json" request the following dependencies "react" and "react-dom" From what I understand the uploadthing package contains everything for the UI and the API but inside the tRPC route the UI isn't necessary so is there a specific package I should use instead of the full uploadthing or is there something wrong to use uploadthing UTApi inside the tRPC route ? here is the error thrown in the terminal when installing/uploading packages :
packages/api
└─┬ next 14.2.3
├── ✕ missing peer react@^18.2.0
├── ✕ missing peer react-dom@^18.2.0
└─┬ styled-jsx 5.1.1
└── ✕ missing peer react@">= 16.8.0 || 17.x.x || ^18.0.0-0"
Peer dependencies that should be installed:
react-dom@^18.2.0 react@">=18.2.0 <19.0.0"
packages/api
└─┬ next 14.2.3
├── ✕ missing peer react@^18.2.0
├── ✕ missing peer react-dom@^18.2.0
└─┬ styled-jsx 5.1.1
└── ✕ missing peer react@">= 16.8.0 || 17.x.x || ^18.0.0-0"
Peer dependencies that should be installed:
react-dom@^18.2.0 react@">=18.2.0 <19.0.0"
I inspected the package-lock file and it s well the uploadthing that request does packages. In advance thanks a lot for your kind help 🙂
1 replies
DTDrizzle Team
Created by john093e on 12/31/2023 in #help
How to fetch and flatten an EAV model ?
Hello dear Drizzle community 🙂 I got a Saas multi-tenant project. Tenants ( called "Organizations" ) have their own Contacts and are capable to add as many Properties as they want and so add Values to does properties for each contact. Objectif is to be as much flexible as possible. I have build my database scheme following principles of an EAV model (entity-attributes-values) . Entity - > Contacts table Attributes -> Properties table Values -> Contacts Properties Values table. I have attached examples of the schemes. Note : json seems good but as the number of properties will grow i though it would be a mess after to much data (please if i'm wrong stop me here 🙂 ) I need help on the following : When fetching contact data, I got the organizationId and an array of the desired properties to fetch containing property id and property name. With the "query" feature using 'findMany' and apply my filters / conditions to fetch users and their properties. I got such return : [{ "contactId": "1XXXXXXXX", "contactsPropertiesValues": [{ "id": "AZERTYXXXX", "valueString": "[email protected]", "valueText": null, "valueDate": null, "valueBoolean": null, }, { "id": "POIUYXXX", "valueString": "John", "valueText": null, "valueDate": null, "valueBoolean": null, }], }, { "contactId": "2XXXXXXXX", "contactsPropertiesValues": [{ "id": "QWERTYXXXX", "valueString": "[email protected]", "valueText": null, "valueDate": null, "valueBoolean": null, }], }] The shape of the result isn't what i search for... Using "select" seems to be the right way for me but I can't get what i want neither. My ultimate goal in this selection is to succeed to return a flatten response like : [{ "contactId" : "1XXXXXXXXXX", "email": "[email protected]", "firstname": "doe", }, { "contactId": "2XXXXXXXXX", "email": "[email protected]", "firstname": null, }]
27 replies