P
Prisma7d ago
dxkyy

Many-to-many relationship not showing in prisma studio?

This is my prisma schema:
model Track {
album Album @relation(fields: [album_id], references: [id])
artists Artist[]
available_markets String[]
disc_number Int
duration_ms Int
explicit Boolean
external_ids Json
external_urls Json
href String
id String @id
name String
popularity Int
preview_url String?
track_number Int
type String
uri String
album_id String
History History[]
Scrobble Scrobble[]
TrackToArtist TrackToArtist[]
}

model TrackToArtist {
Track Track @relation(fields: [track_id], references: [id])
Artist Artist @relation(fields: [artist_id], references: [id])
track_id String
artist_id String

@@id([track_id, artist_id])
}
model Artist {
external_urls Json
href String
id String @id
name String
type String
uri String
tracks Track[]
albums Album[]
TrackToArtist TrackToArtist[]
AlbumToArtist AlbumToArtist[]
}
model Track {
album Album @relation(fields: [album_id], references: [id])
artists Artist[]
available_markets String[]
disc_number Int
duration_ms Int
explicit Boolean
external_ids Json
external_urls Json
href String
id String @id
name String
popularity Int
preview_url String?
track_number Int
type String
uri String
album_id String
History History[]
Scrobble Scrobble[]
TrackToArtist TrackToArtist[]
}

model TrackToArtist {
Track Track @relation(fields: [track_id], references: [id])
Artist Artist @relation(fields: [artist_id], references: [id])
track_id String
artist_id String

@@id([track_id, artist_id])
}
model Artist {
external_urls Json
href String
id String @id
name String
type String
uri String
tracks Track[]
albums Album[]
TrackToArtist TrackToArtist[]
AlbumToArtist AlbumToArtist[]
}
And I'm doing database requests not through prisma, but through sqlx in rust. When I create an entry for track and artist and then connect those in the TrackToArtist table, everything gets inserted to the database, but the relationships are not showing in prisma studio?
No description
2 Replies
dxkyy
dxkyyOP7d ago
const tracks = await prisma.track.findMany({
include: {
artists: true,
},
});
const tracks = await prisma.track.findMany({
include: {
artists: true,
},
});
Also returns an empty artists array.
RaphaelEtim
RaphaelEtim7d ago
Can you do an npx prisma db pull after inserting the data? This will update your Prisma schema to reflect the current state of your database. Then you can try checking Prisma studio again
Want results from more Discord servers?
Add your server