-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Firstable, thank you for your work on this project !
I would like to add a reference to the user entity.
export const User = defineEntity({
name: "User",
tableName: "users",
properties: (p) => ({
...primaryKeyProperty,
firstName: p.string(),
name: p.string(), // This refers to the lastname
email: p.string().nullable(false).unique(),
emailVerified: p.boolean(),
banned: p.boolean().default(false),
banReason: p.string().nullable(),
banExpires: p.datetime().type("timestamptz").nullable(),
image: p.string().type("varchar").nullable(),
// I want to add a reference to the File entity here !
imageFile: () => p.oneToOne(File).nullable(),
//
createdAt: p.datetime().type("timestamptz"),
updatedAt: p.datetime().type("timestamptz"),
sessions: () => p.oneToMany(Session).mappedBy("user"),
accounts: () => p.oneToMany(Account).mappedBy("user"),
messages: () => p.oneToMany(Message).mappedBy("user"),
}),
});In my better-auth config, I tried various things, notably :
export const auth = betterAuth({
// ...
user: {
// I tried various combinaison here but unsuccessfull...
imageFile: { type: "string", input: false, references: { field: "id", model: "files" } },
},
},
});I keep getting an error from the plugin :
api 2026-02-23T15:13:12.178Z ERROR [Better Auth]: BetterAuthError 33 | var import_dset = require("dset");
api 34 |
api 35 | // src/utils/createAdapterError.ts
api 36 | var import_better_auth = require("better-auth");
api 37 | function createAdapterError(message) {
api 38 | throw new import_better_auth.BetterAuthError(`[Mikro ORM Adapter] ${message}`);
api ^
api BetterAuthError: [Mikro ORM Adapter] Can't find property "imageFile" on entity "User".
api at /home/alex/dev/ea-core/node_modules/.bun/better-auth-mikro-orm@0.4.3+84d9f69fd3d49d0b/node_modules/better-auth-mikro-orm/lib/adapter.cjs:38:32
api
api # SERVER_ERROR: 33 | var import_dset = require("dset");
api 34 |
api 35 | // src/utils/createAdapterError.ts
api 36 | var import_better_auth = require("better-auth");
api 37 | function createAdapterError(message) {
api 38 | throw new import_better_auth.BetterAuthError(`[Mikro ORM Adapter] ${message}`);
api ^
api BetterAuthError: [Mikro ORM Adapter] Can't find property "imageFile" on entity "User".
Is this supported ?
Thank you.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels