Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list #51

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Add list #51

wants to merge 5 commits into from

Conversation

n1lsw
Copy link
Contributor

@n1lsw n1lsw commented Feb 21, 2023

No description provided.

@n1lsw n1lsw requested review from dnmct and NoHara42 February 21, 2023 09:57
@n1lsw n1lsw self-assigned this Feb 21, 2023
@n1lsw n1lsw linked an issue Feb 21, 2023 that may be closed by this pull request
.env Outdated
@@ -0,0 +1,13 @@
# Environment variables declared in this file are automatically made available to Prisma.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't commit this file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git rm --cached name_of_file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

package.json Outdated
"eslint": "8.34.0",
"eslint-config-next": "13.1.6",
"fastify": "^4.13.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is fastify installed here? Don't we use next api endpoints?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

package.json Outdated
"eslint": "8.34.0",
"eslint-config-next": "13.1.6",
"fastify": "^4.13.0",
"fastify-zod": "^1.2.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also remove this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


response.status(200).json({ message: "List added successfully" });
} else {
response.status(405).json({ message: "Method not allowed" });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're already adding error handling, why not try catch the prisma client and handle Zod validation errors?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed with 'try' and working by testing with htt page, new list message 200 is there and appearing on prisma studio.

response: NextApiResponse
) {
if (request.method == "GET") {
const list = await prisma.list.findMany({});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, see above comment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed as it was just a test page

tsconfig.json Outdated
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"module": "commonjs",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@NoHara42 NoHara42 removed the request for review from dnmct February 21, 2023 13:21
Copy link
Collaborator

@NoHara42 NoHara42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see changes and reverse merge before submitting a PR

@peelerzin peelerzin requested review from NoHara42 and dnmct February 22, 2023 13:25
@peelerzin peelerzin self-assigned this Feb 22, 2023
model Items {
id String @id @default(uuid())
name String
Linked_to_List List? @relation(fields: [ListID], references: [id])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n1lsw please see Dans comments in discord about naming conventions here and address that in a fix-PR, then merge those changes into this PR from main, once the fix-PR has been merged.

Thanks!

create: {
name: inputList,
},
update: {},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is update empty? Looks like you don't need an upsert here, more like an insert()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit: I meant create(), insert() doesn't exist as a valid prisma method.
If you want to update if there is already an item present, you need to fill this update object

name: "other",
},
data: {
Items: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update with new naming conventions after finishing above comment

Copy link
Collaborator

@NoHara42 NoHara42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments, remember to reverse merge

@TheDoplarEffect TheDoplarEffect marked this pull request as draft February 23, 2023 14:13
@amyria3
Copy link
Collaborator

amyria3 commented Mar 23, 2023

I didn't find this script in main and unfortunately had to write an own one :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add List
5 participants