Skip to content
Discussion options

You must be logged in to vote

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.

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];

Reference

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by riculum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants