I am working on synchronizing a postgresql database with data from a remote API at regular intervals.
The script will make API calls at scheduled times, process the responses, and update the database with the relevant information for each record.
Below is a snippet of the code I have been using to test the functionality of the WHERE statement.
let world = await prisma.world.findFirst({
where: {
Uuid: some_variable.WorldId, //UUID4 string
}
})
However, I encountered the following error:
Type '{ Uuid: string; }' is not assignable to type 'WorldWhereInput'. Object literal may only specify known properties, and 'Uuid' does not exist in type 'WorldWhereInput'.
In the schema provided below, I am wondering if it is possible to query or upsert by the Uuid
field. Additionally, would it be advisable to use an integer-based ID when storing remote data instead of relying on the UUID from the external API?
Considering there will be relationships to other models which are yet to be defined, does this factor impact the decision?
schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
model World {
Id Int @id @default(autoincrement())
Uuid String @unique @db.Uuid
Name String
IsSurvival Boolean @default(false)
IsHumanOnly Boolean @default(false)
Fuel100LLBasePrice Int
FuelJetBasePrice Int
JobsBaseBonus Int
JobsMaxBonus Int
ShortName String
EnableEconomicBalance Boolean @default(false)
}
example response