How to use the pg-promise.errors.queryResultErrorCode function in pg-promise

To help you get started, we’ve selected a few pg-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tomalrussell / colouring-london / app / src / api / services / passwordReset.ts View on Github external
`UPDATE
                user_password_reset_tokens
            SET used = true
            WHERE
            token = $1::uuid
            AND NOT used
            AND now() at time zone 'utc' < expires_on
            RETURNING *`, [token]
            );
        console.log('verified');

        return usedToken.user_id;
    } catch (err) {
        if (err instanceof errors.QueryResultError)  {
            console.log(err.code);
            if (err.code === errors.queryResultErrorCode.noData) return undefined;
        }

        throw err;
    }
}