Hey @sehmaschine, unfortunately I don't think this is possible off the bat with TypeScript.
However, if you care about the naming of this particular field in your code and don't want to use the name of the DB column, you can use @map to give it a different name in your Prisma Client API. If it's a relation field, you can just manually rename it.
Without knowing your schema, it could be be something like this:
model RiskScore { country ConfigurationCountry @@map("risk_scores") } model ConfigurationCountry { riskScore Riskscore @@map("configuration_countries") }
GitHub
github.com › prisma › prisma › discussions › 20346
🔍 Setting Default Select Value for Prisma Fields · prisma/prisma · Discussion #20346
July 23, 2023 - In this example, only the id and name fields will be retrieved from the database, and createdAt, updatedAt, and deletedAt will be excluded. You can also write a Prisma Client extension for this as well. For example: const selectiveRetrievalExtension = { query: { user: { $allOperations({ args, query, operation }) { const { select } = args; // Extract the `select` field from query arguments // If `select` is not provided or doesn't include the special fields, // exclude the `createdAt`, `updatedAt`, and `deletedAt` fields from the query if (!select || (!select.createdAt && !select.updatedAt && !select.deletedAt)) { args.select = { ...select, id: true, name: true, createdAt: false, updatedAt: false, deletedAt: false, }; } return query(args); }, }, }, };
Author prisma
GitHub
github.com › FKLC › graphql-prisma-select-fields
GitHub - FKLC/graphql-prisma-select-fields: Helper library to convert GraphQL document fields to Prisma's select argument
Helper library to convert GraphQL document fields to Prisma's select argument - FKLC/graphql-prisma-select-fields
Author FKLC
Select everything except some fields
I'm using prisma.user.findMany() to select users, but I don't want to select password or any other private field, instead of omitting the fields that I don't want, I have to select all the fields that I want. More on github.com
Change field name with select
I'm trying to rename some fields when using select and it doesn't seem to work ... I'm pretty sure that I'm missing something very basic here ... This is my current query: const data = await prisma... More on github.com
Way to select certain fields from related tables for prisma2
if I query a table together with a related table, how can I select only certain fields of that related table? More on github.com
Tying to use select and include together to create a partial structure
However, for some reason the ... do some kind of hacky solution to combine the selected fields with the type generated with just include, but I was wondering if there is a better way to do what I want natively in Prisma.... More on github.com
GitHub
github.com › prisma › prisma › discussions › 11726
Why are all fields included in a SQL SELECT query? · prisma/prisma · Discussion #11726
Prisma only knows what your code tells Prisma. If you ask the GraphQL query for only a specific field, but then your code calls findMany for all fields, then Prisma will happily get and return all fields.
Author prisma
GitHub
github.com › prisma › prisma › issues › 12894
Select everything except some fields · Issue #12894 · prisma/prisma
April 20, 2022 - prisma.user.findMany({ select: {'*': true, password: false}, orderBy: { createdAt: 'desc' } }) prisma.user.findMany({ deSelect: {password: true}, orderBy: { createdAt: 'desc' } }) // OR prisma.user.findMany({ except: {password: true}, // to align with the SQL keywords. orderBy: { createdAt: 'desc' } }) Issue #8151 can also be addressed along with this. Ex: prisma.user.findMany({ select: { '*': { totalReceivedAmount: 'amount', }, password: false, } orderBy: { createdAt: 'desc' } })
Author prisma
GitHub
github.com › prisma › prisma-client-js › issues › 250
Way to select certain fields from related tables for prisma2 · Issue #250 · prisma/prisma-client-js
September 30, 2019 - Hello *, if I query a table together with a related table, how can I select only certain fields of that related table? const productsResult = await pt.products.findOne({ where: { product_id: id }, include:{ product_variants: true } }); I...
Author prisma
GitHub
github.com › prisma › prisma › issues › 3796
More elegant `select` API by listing fields as array · Issue #3796 · prisma/prisma
September 29, 2020 - The problem is that this is super cumbersome to write as an object with : true for every field. const order = await prisma.order.findOne({ where, select: { id: true, createdAt: true, updatedAt: true, chargeStatus: true, amount: true, customer: { select: { id: true, firstName: true, lastName: true, email: true, phone: true, }, }, orderGroup: { select: { name: true, }, }, }, })
Author prisma
GitHub
github.com › prisma › prisma › discussions › 13395
How to handle multiple joins with select field? · prisma/prisma · Discussion #13395
select p.programme, p.display_name, ep.is_active as entreprise_active, ap.is_active as agency_active, p.is_active as tenant_active from "Product" p inner join "EntrepriseProduct" ep on p.programme = ep."productId" inner join "AgencyProduct" ap on ep."entrepriseId" = ( select a."entrepriseId" from "Agency" a where a.id = ${agencyId} ) and ep."productId" = ap."productId"
Author prisma
GitHub
github.com › prisma › prisma › discussions › 7773
How to select almost all fields and except some fields. · prisma/prisma · Discussion #7773
I want to know How to select almost all fields and except some fields on the table. ... const result = await prisma.user.findUnique({ where: { id: 1 }, select: { except: [field_name_1, ....
Author prisma
Prisma
prisma.io › home › excluding fields › excluding fields › excluding fields › excluding fields
Excluding fields | Prisma Documentation
Select fields · Prisma Client API reference · Edit on GitHub · Select fields · Learn how to return only the fields and relations you need with select and include in Prisma Client. Relation queries · Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters ·
GitHub
github.com › prisma › prisma › issues › 13550
Prisma client - "select" behaviors · Issue #13550 - GitHub
May 29, 2022 - all-fields - acts like select statement works now (selects all fields) optional - allows user not to add "select" statement to query, in this case null must be returned by the request required - requires query to have a "select" statement and specify all the fields we want to get in the response
Author prisma
GitHub
github.com › prisma › prisma › issues › 2431
Option to select inside `Json` fields · Issue #2431 · prisma/prisma
May 13, 2020 - kind/featureA request for a new feature.A request for a new feature.topic: JsonScalar type `Json`Scalar type `Json`topic: client apitopic: client typesTypes in Prisma ClientTypes in Prisma Client ... A JSON field in a database might contain a lot of data that you don't necessarily want to return each time you read a record - e.g. unstructured analytics data. Would it be possible to have some way to include/omit a JSON field, or (depending on db support) select what part of a JSON field you want to include in the response?
Author prisma
GitHub
github.com › prisma › prisma › issues › 21646
Custom field client extension not working with select · Issue #21646 · prisma/prisma
October 27, 2023 - When select contains the fields defined in needs, the computed property should be available in the result object. Environment variables loaded from .env prisma : 5.5.2 @prisma/client : 5.5.2 Current platform : darwin-arm64 Query Engine (Node-API) : libquery-engine aebc046ce8b88ebbcb45efe31...
Author prisma
npm
npmjs.com › package › prisma-parse-selected-fields
prisma-parse-selected-fields - npm
May 24, 2022 - npm i prisma-parse-selected-fields · github.com/nqnghia285/prisma-parse-selected-fields · github.com/nqnghia285/prisma-parse-selected-fields.git#readme · 5 · 1.1.10 · MIT · 41.6 kB · 49 · 3 years ago · nqnghia285 · Try on RunKit ·
» npm install prisma-parse-selected-fields
Published May 24, 2022
Version 1.1.10
Author nghia
GitHub
github.com › prisma › prisma › issues › 24708
Add "select as" support · Issue #24708 · prisma/prisma
July 5, 2024 - // Prisma will generate type like this for result type UserWithFullName = { fullName: string; }; const users = prisma.user.findMany({ select: { name: true, }, }); const usersWithFullName: UserWithFullName[] = users.map((user) => ({ ...user, fullName: user.name, })); This can be difficult in the case of nested objects · Implementation can transform field name both in the SQL query (with native AS) and when processing the results
Author prisma