Rich Starkie
01/24/2022, 10:47 PM[]
I've tried what the docs say to connect to the remote field as the fields are populated earlier in the script, but I've also tried a create with the same results.
Here's a couple of code blocks that may help ...
await prisma.<table>.create{(
...
releaseShelf:{ // releaseShelf is the name of the Relation in Schema - linked table is libraryShelves
connect: {shelfId: variable}, // shelfId is the PK field of the table
}
)}
Schema
Main Table
model libraryReleases {
releaseId String @id @db.VarChar(255)
releaseMasterId String @default("-1") @db.VarChar(255)
releaseDiscogsPage String @default("#") @db.VarChar(1024)
releaseDiscogsImageUrl String @default("#") @db.VarChar(1024)
releaseLocalImage String @default("images/coming_soon.png") @db.VarChar(1024)
releaseTitle String @db.VarChar(512)
releaseSortLetter String @default("-") @db.VarChar(1)
releaseSortName String @default("-") @db.VarChar(512)
releaseCatalogueNumber String @default("-") @db.VarChar(512)
releaseYear Int @default(0)
releaseNumberDiscs Int @default(0)
releaseReviewRating Decimal @default(0) @db.Decimal(2, 1)
releaseTimesPlayed Int @default(0)
releaseLastPlayed DateTime @default(dbgenerated("'1970-01-01 01:00:01+01'::timestamp with time zone")) @db.Timestamptz(6)
releaseAddedToDiscogs DateTime @default(dbgenerated("'1970-01-01 01:00:01+01'::timestamp with time zone")) @db.Timestamptz(6)
releaseTracksAdded DateTime @default(dbgenerated("'1970-01-01 01:00:01+01'::timestamp with time zone")) @db.Timestamptz(6)
releaseDecade50s Boolean? @default(false)
releaseDecade60s Boolean? @default(false)
releaseDecade70s Boolean? @default(false)
releaseDecade80s Boolean? @default(false)
releaseDecade90s Boolean? @default(false)
releaseDecade00s Boolean? @default(false)
releaseDecade10s Boolean? @default(false)
releaseDecade20s Boolean? @default(false)
releaseLibrary Boolean? @default(false)
releaseWantlist Boolean? @default(false)
releaseSlug String @unique @db.VarChar(300)
createdAt DateTime @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
releaseArtists libraryArtists[]
releaseFormats libraryFormats[]
releaseStyle libraryStyles[]
releaseGenres libraryGenres[]
releaseCurrentLocation libraryLocations[] @relation(name: "currentLocation")
releaseLibraryLocation libraryLocations[] @relation(name: "libraryLocation")
releaseRecordLabel libraryRecordLabels[]
releaseShelf libraryShelves[]
releaseTracks libraryTracks[]
releaseUnavailableReason libraryUnavailableReasons[] @relation(name: "releaseUnavailable")
}
Shelf Table
model libraryShelves {
shelfId String @id @db.VarChar(255)
shelfName String @db.VarChar(255)
shelfCount Int @default(0)
shelfSlug String @unique @db.VarChar(300)
createdAt DateTime @db.Timestamptz(6)
updatedAt DateTime @db.Timestamptz(6)
shelfRelease libraryReleases[]
}
This gives an error :
Unknown arg `releaseShelf` in data.releaseShelf for type libraryReleasesUncheckedCreateInput.
Any help much appreciated
Thanks 😄n
01/25/2022, 12:17 AMType 'Account' is not assignable to type 'AccountModel'.
Types of property 'balance' are incompatible.
Type 'Decimal' is not assignable to type 'string | number'.
Type 'Decimal' is not assignable to type 'number'.ts(2322)
Chuan WU
01/25/2022, 4:56 AMmodel SettingKey {
id Int @id @default(autoincrement())
productType ProductType
key String
label String
valueType DataType
Setting Setting[]
}
model SettingValue {
id Int @id @default(autoincrement())
productId Int
keyId Int
value String
product Product? @relation(fields: [productId], references: [id])
@@index([productId], name: "fk_product")
key SettingKey? @relation(fields: [keyId], references: [id])
@@index([keyId], name: "fk_key")
}
ArcticSpaceFox
01/25/2022, 4:50 PMWilliam Albright
01/25/2022, 5:51 PMWilliam Albright
01/25/2022, 5:59 PMOkan Yıldırım
01/25/2022, 7:25 PMOkan Yıldırım
01/25/2022, 7:25 PMOkan Yıldırım
01/25/2022, 7:25 PMOkan Yıldırım
01/25/2022, 7:26 PMFranco Roura
01/25/2022, 7:26 PMschema.prisma
file has a @map('snake_case') equivalent. Does prisma have any kind of AST builtin tool or should I just read the file and parse it with js?Okan Yıldırım
01/25/2022, 7:27 PMOkan Yıldırım
01/25/2022, 7:27 PMprisma.post.findUnique({id: 1, select: { user: true } })
Okan Yıldırım
01/25/2022, 7:27 PMOkan Yıldırım
01/25/2022, 7:27 PMador
01/25/2022, 9:14 PMOleg Komarov
01/25/2022, 9:18 PMDb
so it’s clear that the queried object is of type e.g. DbUser and not the any other mapping in the code?
Just wasted 2 hours debugging an obscure issue to find out I forgot to map the database type to the requested type since they have the same name 🤦♂️ador
01/25/2022, 9:20 PMconst categories = await this.tableIds.categories.findMany()
with tableIds it works just fine, but when I try categories
:
const categories = await this.prisma.categories.findMany()
it just Cannot read properties of undefined (reading 'findMany')
both are models in schema.prisma
ador
01/25/2022, 9:22 PMcategories
and products
doesn't work for some reasonador
01/25/2022, 9:22 PMWade McDaniel
01/25/2022, 11:41 PMbinaryTargets = ["native", "rhel-openssl-1.0.x"]
?
I'd like to generate the linux binaries so I can upload them to a linux serverless instance, but all I get in windows is "native" binaries.Darian Sampare
01/25/2022, 11:52 PMador
01/26/2022, 3:46 PMBarnaby
01/26/2022, 4:02 PMsampoder
01/26/2022, 4:06 PMAndré
01/26/2022, 4:19 PMSebastian Rindom
01/26/2022, 4:55 PMmedusa migrations run
will ensure that all missing migrations from core + plugins are applied
Trying to map this to Prisma my thinking so far is this:
• Core + Plugins will have schema.prisma
• Core + Plugins will have migrations
• *Core will programmatically collect migrations and call Prisma Migrate
• *Core programatically creates a Prisma client that is unique to the user’s core + plugins combination
My questions are about the last two steps marked with * - 1) are these steps possible and recommended and 2) are there alternative approaches that would be betterChris Tsongas
01/26/2022, 7:08 PMpackages
folder for use by multiple apps
?Matt Furden
01/26/2022, 9:18 PM