trufflesuite / drizzle

Reactive Ethereum dapp UI suite
907 stars 238 forks source link

How can you implement multi-tenant access to data? #155

Open cleverid opened 8 months ago

cleverid commented 8 months ago

After authorization, the user with his tenant_id makes a request to the database.

How to make it so as not to add this tenant_id manually to the where section?

From ORM query:

    const users = await orm
      .select()
      .from(userSchema)
      .where(eq(userSchema.tenant_id, this.tenant_id)); // Users for tenant_id. Filter added as handly

To:

    const users = await orm
      .select()
      .from(userSchema) // But the request has tenant_id as a result of the SQL query