findOne -> findUnique

This commit is contained in:
Rob Cameron
2021-01-07 14:15:07 -08:00
parent 87602079f6
commit 81372de63b
2 changed files with 5 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
// to return a real user from your database, you could do something like: // to return a real user from your database, you could do something like:
// //
// export const getCurrentUser = async ({ email }) => { // export const getCurrentUser = async ({ email }) => {
// return await db.user.findOne({ where: { email } }) // return await db.user.fineUnique({ where: { email } })
// } // }
// //
// If you want to enforce role-based access ... // If you want to enforce role-based access ...
@@ -67,7 +67,7 @@ import { AuthenticationError, ForbiddenError, parseJWT } from '@redwoodjs/api'
* @example - No role-based access control. * @example - No role-based access control.
* *
* export const getCurrentUser = async (decoded) => { * export const getCurrentUser = async (decoded) => {
* return await db.user.findOne({ where: { decoded.email } }) * return await db.user.fineUnique({ where: { decoded.email } })
* } * }
* *
* @example - User info is conatined in the decoded token and roles extracted * @example - User info is conatined in the decoded token and roles extracted
@@ -79,7 +79,7 @@ import { AuthenticationError, ForbiddenError, parseJWT } from '@redwoodjs/api'
* @example - User record query by email with namespaced app_metadata roles * @example - User record query by email with namespaced app_metadata roles
* *
* export const getCurrentUser = async (decoded) => { * export const getCurrentUser = async (decoded) => {
* const currentUser = await db.user.findOne({ where: { email: decoded.email } }) * const currentUser = await db.user.fineUnique({ where: { email: decoded.email } })
* *
* return { * return {
* ...currentUser, * ...currentUser,
@@ -90,7 +90,7 @@ import { AuthenticationError, ForbiddenError, parseJWT } from '@redwoodjs/api'
* @example - User record query by an identity with app_metadata roles * @example - User record query by an identity with app_metadata roles
* *
* const getCurrentUser = async (decoded) => { * const getCurrentUser = async (decoded) => {
* const currentUser = await db.user.findOne({ where: { userIdentity: decoded.sub } }) * const currentUser = await db.user.fineUnique({ where: { userIdentity: decoded.sub } })
* return { * return {
* ...currentUser, * ...currentUser,
* roles: parseJWT({ decoded: decoded }).roles, * roles: parseJWT({ decoded: decoded }).roles,

View File

@@ -6,7 +6,7 @@ export const posts = () => {
} }
export const post = ({ id }) => { export const post = ({ id }) => {
return db.post.findOne({ return db.post.findUnique({
where: { id }, where: { id },
}) })
} }