update additional field on user object via route handler

in my route handler, how can i update this additional value? is there a method in the api, or do i just update the document by querying mongodb:
user: {
additionalFields: {

raw_data_mongo_ref_id: {
type: "string",
required: false,
default: "null",
input: false, // don't allow users to set this value
},
},
},
user: {
additionalFields: {

raw_data_mongo_ref_id: {
type: "string",
required: false,
default: "null",
input: false, // don't allow users to set this value
},
},
},
6 Replies
daveycodez
daveycodez4mo ago
in a database after hook you could set this
Elite
EliteOP4mo ago
So after they save something to db, do I make a after hook? And in that it edits the database field of the user array in mongo? What would the condition to run it be
daveycodez
daveycodez4mo ago
idk depends on your goal
Elite
EliteOP4mo ago
I just wanna add a field to the user after they upload something to my site
Ping
Ping4mo ago
I believe you miss understood him, in Better-Auth, we have database hooks: https://www.better-auth.com/docs/concepts/database#database-hooks
Database | Better Auth
Learn how to use a database with Better Auth.
Elite
EliteOP4mo ago
Ahh I see thanks

Did you find this page helpful?