How to return custom session with modified DB fields

Hi there, Currently to created custom session you do something along lines of:
customSession(async ({user, session}) => {
return {
user,
session
};
})
customSession(async ({user, session}) => {
return {
user,
session
};
})
If I modified the user fields that are saved to the db as follows:
user: {
fields: {
emailVerified: "email_verified",
createdAt: "date_created",
updatedAt: "date_updated"
},
}
user: {
fields: {
emailVerified: "email_verified",
createdAt: "date_created",
updatedAt: "date_updated"
},
}
I would expect that user in custom session to have email_verified, date_created etc. However as per attached image I am not seeing this as the case. Is there a reason for this?
No description
2 Replies
j_slno
j_slno5d ago
its just changing the column names in the database, not the variable names. You can assign it manually though, or in your case you could write a function that converts the keys from camel to snake case.
CodingWithLuke
CodingWithLukeOP5d ago
Yeah was kinda hoping that they would use our keys we gave when configuring to then return that modified versions.

Did you find this page helpful?