Hello, I’m trying to create a sign-up function which will test if there are any user accounts in the database with a given username and, if not, create a user. I have so far followed the approach of making the username prop unique in the database, and using try/catch
statements to create the account. Here’s the code:
export async function createUser(email, username, password) {
try {
await client.query(
q.Create('user', {
data: {
username: username,
password: password,
email: email,
},
})
);
return true;
} catch (e) {
return false;
}
}
I was just wondering if this is good practice or if making the database send an error to my application whenever a user cannot be created is problematic for runtime, robustness, etc. Thank you