dxkyy
dxkyy
PPrisma
Created by dxkyy on 12/11/2024 in #help-and-questions
Many-to-many relationship not showing in prisma studio?
const tracks = await prisma.track.findMany({
include: {
artists: true,
},
});
const tracks = await prisma.track.findMany({
include: {
artists: true,
},
});
Also returns an empty artists array.
3 replies
PPrisma
Created by dxkyy on 12/11/2024 in #help-and-questions
Can I access a database, which was created with prisma, with a normal sql driver?
i think it has something to do with the relations, how do I fix that?
9 replies
PPrisma
Created by dxkyy on 12/11/2024 in #help-and-questions
Can I access a database, which was created with prisma, with a normal sql driver?
this is the code thats causing problems:
let artist_exists = sqlx::query("SELECT * FROM \"Artist\" WHERE id = $1").bind(artist.id.clone()).fetch_one(pool).await;
match artist_exists {
Ok(_) => {
info!("Artist exists: {}", artist.name);
info!("Database: {:?}", artist_exists);
}
Err(_) => {
info!("Artist does not exist: {}", artist.name);
let created = sqlx::query("INSERT INTO \"Artist\" (external_urls, href, id, name, r#type, uri) VALUES ($1, $2, $3, $4, $5, $6) RETURNING name").bind(artist.external_urls.clone()).bind(artist.href.clone()).bind(artist.id.clone()).bind(artist.name.clone()).bind(artist.r#type.clone()).bind(artist.uri.clone()).execute(pool).await;
info!("Created: {:?}", created);
}
}
let artist_exists = sqlx::query("SELECT * FROM \"Artist\" WHERE id = $1").bind(artist.id.clone()).fetch_one(pool).await;
match artist_exists {
Ok(_) => {
info!("Artist exists: {}", artist.name);
info!("Database: {:?}", artist_exists);
}
Err(_) => {
info!("Artist does not exist: {}", artist.name);
let created = sqlx::query("INSERT INTO \"Artist\" (external_urls, href, id, name, r#type, uri) VALUES ($1, $2, $3, $4, $5, $6) RETURNING name").bind(artist.external_urls.clone()).bind(artist.href.clone()).bind(artist.id.clone()).bind(artist.name.clone()).bind(artist.r#type.clone()).bind(artist.uri.clone()).execute(pool).await;
info!("Created: {:?}", created);
}
}
9 replies
PPrisma
Created by dxkyy on 12/11/2024 in #help-and-questions
Can I access a database, which was created with prisma, with a normal sql driver?
yes, exactly
9 replies
PPrisma
Created by dxkyy on 12/11/2024 in #help-and-questions
Can I access a database, which was created with prisma, with a normal sql driver?
but i also need to access the same database in a rust project, and prisma-client-rust is not an option for me
9 replies
PPrisma
Created by dxkyy on 12/11/2024 in #help-and-questions
Can I access a database, which was created with prisma, with a normal sql driver?
Oh, no i created it using the prisma client in a typescript project
9 replies