Upgrade redwood to 0.25.0
changes from sql to postgress for dev, super stressful
This commit is contained in:
@@ -59,7 +59,7 @@ export const handler = async (req, _context) => {
|
||||
if (eventType === 'signup') {
|
||||
roles.push('user')
|
||||
const isUniqueCallback = async (seed) =>
|
||||
db.user.findOne({
|
||||
db.user.findUnique({
|
||||
where: { userName: seed },
|
||||
})
|
||||
const userNameSeed = enforceAlphaNumeric(user?.user_metadata?.userName)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// to return a real user from your database, you could do something like:
|
||||
//
|
||||
// export const getCurrentUser = async ({ email }) => {
|
||||
// return await db.user.findOne({ where: { email } })
|
||||
// return await db.user.findUnique({ where: { email } })
|
||||
// }
|
||||
//
|
||||
// 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.
|
||||
*
|
||||
* export const getCurrentUser = async (decoded) => {
|
||||
* return await db.user.findOne({ where: { decoded.email } })
|
||||
* return await db.user.findUnique({ where: { decoded.email } })
|
||||
* }
|
||||
*
|
||||
* @example - User info is contained 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
|
||||
*
|
||||
* export const getCurrentUser = async (decoded) => {
|
||||
* const currentUser = await db.user.findOne({ where: { email: decoded.email } })
|
||||
* const currentUser = await db.user.findUnique({ where: { email: decoded.email } })
|
||||
*
|
||||
* return {
|
||||
* ...currentUser,
|
||||
@@ -90,7 +90,7 @@ import { AuthenticationError, ForbiddenError, parseJWT } from '@redwoodjs/api'
|
||||
* @example - User record query by an identity with app_metadata roles
|
||||
*
|
||||
* const getCurrentUser = async (decoded) => {
|
||||
* const currentUser = await db.user.findOne({ where: { userIdentity: decoded.sub } })
|
||||
* const currentUser = await db.user.findUnique({ where: { userIdentity: decoded.sub } })
|
||||
* return {
|
||||
* ...currentUser,
|
||||
* roles: parseJWT({ decoded: decoded }).roles,
|
||||
|
||||
@@ -21,7 +21,7 @@ export const requireOwnership = async ({ userId, userName, partId } = {}) => {
|
||||
}
|
||||
|
||||
if (userName) {
|
||||
const user = await db.user.findOne({
|
||||
const user = await db.user.findUnique({
|
||||
where: { userName },
|
||||
})
|
||||
|
||||
@@ -32,7 +32,7 @@ export const requireOwnership = async ({ userId, userName, partId } = {}) => {
|
||||
|
||||
if (partId) {
|
||||
const user = await db.part
|
||||
.findOne({
|
||||
.findUnique({
|
||||
where: { id: partId },
|
||||
})
|
||||
.user()
|
||||
|
||||
@@ -6,7 +6,7 @@ export const comments = () => {
|
||||
}
|
||||
|
||||
export const comment = ({ id }) => {
|
||||
return db.comment.findOne({
|
||||
return db.comment.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export const deleteComment = ({ id }) => {
|
||||
|
||||
export const Comment = {
|
||||
user: (_obj, { root }) =>
|
||||
db.comment.findOne({ where: { id: root.id } }).user(),
|
||||
db.comment.findUnique({ where: { id: root.id } }).user(),
|
||||
part: (_obj, { root }) =>
|
||||
db.comment.findOne({ where: { id: root.id } }).part(),
|
||||
db.comment.findUnique({ where: { id: root.id } }).part(),
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export const partReactions = () => {
|
||||
}
|
||||
|
||||
export const partReaction = ({ id }) => {
|
||||
return db.partReaction.findOne({
|
||||
return db.partReaction.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
}
|
||||
@@ -62,7 +62,7 @@ export const deletePartReaction = ({ id }) => {
|
||||
|
||||
export const PartReaction = {
|
||||
user: (_obj, { root }) =>
|
||||
db.partReaction.findOne({ where: { id: root.id } }).user(),
|
||||
db.partReaction.findUnique({ where: { id: root.id } }).user(),
|
||||
part: (_obj, { root }) =>
|
||||
db.partReaction.findOne({ where: { id: root.id } }).part(),
|
||||
db.partReaction.findUnique({ where: { id: root.id } }).part(),
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ export const parts = ({ userName }) => {
|
||||
}
|
||||
|
||||
export const part = ({ id }) => {
|
||||
return db.part.findOne({
|
||||
return db.part.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
}
|
||||
export const partByUserAndTitle = async ({ userName, partTitle }) => {
|
||||
const user = await db.user.findOne({
|
||||
const user = await db.user.findUnique({
|
||||
where: {
|
||||
userName,
|
||||
},
|
||||
})
|
||||
return db.part.findOne({
|
||||
return db.part.findUnique({
|
||||
where: {
|
||||
title_userId: {
|
||||
title: partTitle,
|
||||
@@ -54,7 +54,7 @@ export const forkPart = async ({ input }) => {
|
||||
// Only difference between create and fork part is that fork part will generate a unique title
|
||||
// (for the user) if there is a conflict
|
||||
const isUniqueCallback = async (seed) =>
|
||||
db.part.findOne({
|
||||
db.part.findUnique({
|
||||
where: {
|
||||
title_userId: {
|
||||
title: seed,
|
||||
@@ -75,7 +75,7 @@ export const updatePart = async ({ id, input }) => {
|
||||
if (input.title) {
|
||||
input.title = enforceAlphaNumeric(input.title)
|
||||
}
|
||||
const originalPart = await db.part.findOne({ where: { id } })
|
||||
const originalPart = await db.part.findUnique({ where: { id } })
|
||||
const imageToDestroy =
|
||||
originalPart.mainImage !== input.mainImage && originalPart.mainImage
|
||||
const update = await db.part.update({
|
||||
@@ -102,11 +102,12 @@ export const deletePart = async ({ id }) => {
|
||||
}
|
||||
|
||||
export const Part = {
|
||||
user: (_obj, { root }) => db.part.findOne({ where: { id: root.id } }).user(),
|
||||
user: (_obj, { root }) =>
|
||||
db.part.findUnique({ where: { id: root.id } }).user(),
|
||||
Comment: (_obj, { root }) =>
|
||||
db.part.findOne({ where: { id: root.id } }).Comment(),
|
||||
db.part.findUnique({ where: { id: root.id } }).Comment(),
|
||||
Reaction: (_obj, { root }) =>
|
||||
db.part
|
||||
.findOne({ where: { id: root.id } })
|
||||
.findUnique({ where: { id: root.id } })
|
||||
.Reaction({ where: { userId: _obj.userId } }),
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export const subjectAccessRequests = () => {
|
||||
|
||||
export const subjectAccessRequest = ({ id }) => {
|
||||
requireAuth({ role: 'admin' })
|
||||
return db.subjectAccessRequest.findOne({
|
||||
return db.subjectAccessRequest.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
}
|
||||
@@ -38,5 +38,5 @@ export const deleteSubjectAccessRequest = ({ id }) => {
|
||||
|
||||
export const SubjectAccessRequest = {
|
||||
user: (_obj, { root }) =>
|
||||
db.subjectAccessRequest.findOne({ where: { id: root.id } }).user(),
|
||||
db.subjectAccessRequest.findUnique({ where: { id: root.id } }).user(),
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ export const users = () => {
|
||||
}
|
||||
|
||||
export const user = ({ id }) => {
|
||||
return db.user.findOne({
|
||||
return db.user.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
}
|
||||
|
||||
export const userName = ({ userName }) => {
|
||||
return db.user.findOne({
|
||||
return db.user.findUnique({
|
||||
where: { userName },
|
||||
})
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export const updateUserByUserName = async ({ userName, input }) => {
|
||||
`You've tried to used a protected word as you userName, try something other than `
|
||||
)
|
||||
}
|
||||
const originalPart = await db.user.findOne({ where: { userName } })
|
||||
const originalPart = await db.user.findUnique({ where: { userName } })
|
||||
const imageToDestroy =
|
||||
originalPart.image !== input.image && originalPart.image
|
||||
const update = await db.user.update({
|
||||
@@ -73,10 +73,11 @@ export const deleteUser = ({ id }) => {
|
||||
}
|
||||
|
||||
export const User = {
|
||||
Parts: (_obj, { root }) => db.user.findOne({ where: { id: root.id } }).Part(),
|
||||
Parts: (_obj, { root }) =>
|
||||
db.user.findUnique({ where: { id: root.id } }).Part(),
|
||||
Part: (_obj, { root }) =>
|
||||
_obj.partTitle &&
|
||||
db.part.findOne({
|
||||
db.part.findUnique({
|
||||
where: {
|
||||
title_userId: {
|
||||
title: _obj.partTitle,
|
||||
@@ -85,9 +86,9 @@ export const User = {
|
||||
},
|
||||
}),
|
||||
Reaction: (_obj, { root }) =>
|
||||
db.user.findOne({ where: { id: root.id } }).Reaction(),
|
||||
db.user.findUnique({ where: { id: root.id } }).Reaction(),
|
||||
Comment: (_obj, { root }) =>
|
||||
db.user.findOne({ where: { id: root.id } }).Comment(),
|
||||
db.user.findUnique({ where: { id: root.id } }).Comment(),
|
||||
SubjectAccessRequest: (_obj, { root }) =>
|
||||
db.user.findOne({ where: { id: root.id } }).SubjectAccessRequest(),
|
||||
db.user.findUnique({ where: { id: root.id } }).SubjectAccessRequest(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user