Background
I'm implementing an API endpoint for creating a user with MikroORM. Requirement tells me that I need the user info saved on a PostgreSQL server—except for user password; I need the passwords stored on the Firebase Authentication backend for some reason.
Wanted Behavior
I'm trying to get the following to work.
const newUser = new User({
email: '[email protected]',
password: 'mypassword'
});
em.persist(newUser).flush(); // save email to Postgres, save password to Firebase
My failed attempt at the solution
I'm trying to lean on MikroORM's Virtual Properties feature.
@Entity()
class User {
/** -- snipped -- */
@Property({ type: 'varchar', length: 50 })
email!: number;
@Property({ persist: false })
set password(value: string) {
setPasswordOnFirebase(this, value); // password gets saved before persist and flush
// how to even handle async saving and errors?
}
}
Questions
Is it possible in MikroORM to accomplish the wanted behavior I have in mind? Or should I simply create a separate endpoint for custom storing of password?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745247781a4618492.html
评论列表(0条)