How to exclude certain fields from the selection? #1355
-
I’m using Drizzle ORM in my TypeScript project to work with a database, and I have a model representing user data that includes sensitive information like passwords. I want to exclude the ‘password’ field by default in all SELECT statements for security reasons. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I can't think of a way to exclude a field, but you can pick what fields should be select. Like this: const result = await db.select({
field1: users.id,
field2: users.name,
}).from(users);
const { field1, field2 } = result[0]; |
Beta Was this translation helpful? Give feedback.
I can't think of a way to exclude a field, but you can pick what fields should be select. Like this:
Reference