Architectural question regarding customers of an org

Hey folks! As better-auth uses membership based architecture for organisation plugin, I started contemplating if a guest_customer and paid_customer should be members of an org or a separate entity like in the code below. What's your experience with this?
export const auth = betterAuth({
plugins: [
organization({
// Only for restaurant staff
roles: {
owner: ownerRole, // Restaurant owner
admin: adminRole, // Manager
member: memberRole, // Employee
}
}),
],
user: {
additionalFields: {
role: {
type: "string",
required: false,
defaultValue: "guest",
input: false, // Server controls role assignment
},
},
},
});



// Custom customer table (outside organization plugin)
export const restaurantCustomer = pgTable("restaurant_customer", {
id: text("id").primaryKey(),
userId: text("user_id").notNull().references(() => user.id),
restaurantId: text("restaurant_id").notNull().references(() => organization.id),
customerType: text("customer_type").notNull(), // "paid" or "guest"
createdAt: timestamp("created_at").defaultNow().notNull(),
});
export const auth = betterAuth({
plugins: [
organization({
// Only for restaurant staff
roles: {
owner: ownerRole, // Restaurant owner
admin: adminRole, // Manager
member: memberRole, // Employee
}
}),
],
user: {
additionalFields: {
role: {
type: "string",
required: false,
defaultValue: "guest",
input: false, // Server controls role assignment
},
},
},
});



// Custom customer table (outside organization plugin)
export const restaurantCustomer = pgTable("restaurant_customer", {
id: text("id").primaryKey(),
userId: text("user_id").notNull().references(() => user.id),
restaurantId: text("restaurant_id").notNull().references(() => organization.id),
customerType: text("customer_type").notNull(), // "paid" or "guest"
createdAt: timestamp("created_at").defaultNow().notNull(),
});
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?