this is the workflow ```js const hash = utils.hashPassword(request.json.password); c

this is the workflow
        const hash = utils.hashPassword(request.json.password);
        const account = await env.DB.prepare("INSERT INTO users (email, password, firstname, lastname) VALUES (?, ?, ?, ?) RETURNING pk;")
            .bind(request.json.email, hash, request.json.firstname, request.json.lastname)
            .run();

        if (!account.success) throw new Error();

        const snowflake = utils.createSnowflake(account.results[0].pk);
        const set_id = await env.DB.prepare("UPDATE users SET id = ? WHERE pk = ?;")
            .bind(snowflake, account.results[0].pk)
            .run();
            
        if (!set_id.success) throw new Error();
Was this page helpful?