kgtrey1
kgtrey1
PPrisma
Created by kgtrey1 on 7/3/2024 in #help-and-questions
how to import prisma client on a client without compromising credentials
import type { Status } from '@prisma/client'

export const changeStatus = (status: Status) => {
// send something to the api
}
import type { Status } from '@prisma/client'

export const changeStatus = (status: Status) => {
// send something to the api
}
import type { Status } from '@prisma/client'
import { changeStatus } from 'adapters'

const onConnect = () => {
changeStatus(Status.AVAILABLE) // this will throw
}
import type { Status } from '@prisma/client'
import { changeStatus } from 'adapters'

const onConnect = () => {
changeStatus(Status.AVAILABLE) // this will throw
}
In this case, I don't think I can use the enum, but I might be able to hardcode it like and still benefit type safety
import { changeStatus } from 'adapters'

const onConnect = () => {
changeStatus("AVAILABLE")
}
import { changeStatus } from 'adapters'

const onConnect = () => {
changeStatus("AVAILABLE")
}
If my enum looks something like:
enum Status {
AVAILABLE = "AVAILABLE",
DISCONNECTED = "DISCONNECTED"
}
enum Status {
AVAILABLE = "AVAILABLE",
DISCONNECTED = "DISCONNECTED"
}
I need to check but I think it might be ok, thanks for the idea If anybody comes around here and have another take on this subject, then I would be glad to hear about it
10 replies
PPrisma
Created by kgtrey1 on 7/3/2024 in #help-and-questions
how to import prisma client on a client without compromising credentials
But I might miss a point
10 replies
PPrisma
Created by kgtrey1 on 7/3/2024 in #help-and-questions
how to import prisma client on a client without compromising credentials
I agree with that, but if it's an enum, it's a value and not a type and in this case, it won't work
10 replies
PPrisma
Created by kgtrey1 on 7/3/2024 in #help-and-questions
how to import prisma client on a client without compromising credentials
I'm sorry but I didn't get what you said I'm aware that I could import as "type" and that the imports would be remove after transpilation, but I'm not sure it will be the case if I use enum in my prisma schema because enums (if my memory is good, I could be wrong) are considered as object and I plan on using enum anyway. I'm looking for a way to only expose my entities types to the RN app without having a lot of things to do once I change something in the schema
10 replies