schettn
schettn
PPrisma
Created by schettn on 9/16/2024 in #help-and-questions
Lazy load query engine in Cloudflare Workers
Hi! When using previewFeatures = ["driverAdapters"] deploying to most free plans fail due to the bundle size limit of 1mb. This is caused by the added bundle size of the query engine wasm. Wouldnt it be possible to lazy load the wasm when the worker is executed? - With that, the bundle would be reduced by 2MB. - Yes the execution of the worker would take longer, but I think this doesnt really matter in most cases - The Cloudflare Worker free plan offers 128mb of RAM. So it would be possible to lazy load the query engine. https://github.com/prisma/prisma/issues/23350
3 replies
PPrisma
Created by schettn on 7/31/2024 in #help-and-questions
Why do i need a Prisma account for database subscriptions?
I wanted to use subscriptions for my application. I read that this can be achived with Pulse. But why exactly do I need the prisma cloud for that? In Prisma V1 subscribing to the database was possible without a cloud. https://www.prisma.io/blog/tutorial-building-a-realtime-graphql-server-with-subscriptions-2758cfc6d427
2 replies
PPrisma
Created by schettn on 7/12/2024 in #help-and-questions
How to use getDMMF
I use the following code to load the dmmf from a absolute path:
const PYLON_ABSOLUTE_PATH = '/Users/schettn/Documents/pylon/pylon-template'

import {getDMMF} from '@prisma/internals'
// import {getDMMF} from '@prisma/sdk'

export default defineService({
Query: {
async prismaDMMF() {
console.log(process.cwd())

const dmmf = await getDMMF({
datamodelPath: path.join(PYLON_ABSOLUTE_PATH, 'prisma/schema.prisma')
})

return dmmf
}
}
})
const PYLON_ABSOLUTE_PATH = '/Users/schettn/Documents/pylon/pylon-template'

import {getDMMF} from '@prisma/internals'
// import {getDMMF} from '@prisma/sdk'

export default defineService({
Query: {
async prismaDMMF() {
console.log(process.cwd())

const dmmf = await getDMMF({
datamodelPath: path.join(PYLON_ABSOLUTE_PATH, 'prisma/schema.prisma')
})

return dmmf
}
}
})
I get the following error:
GraphQLError: Get DMMF: Unable to resolve path to query-engine binary
Details: Could not find libquery-engine binary. Searched in:
- /Users/schettn/Documents/pylon/packages/pylon-server/studio-pylon/libquery_engine-darwin-arm64.dylib.node
- /Users/schettn/Documents/pylon/packages/pylon-server/studio-pylon/libquery_engine-darwin-arm64.dylib.node
- /Users/schettn/Documents/pylon/packages/pylon-server/libquery_engine-darwin-arm64.dylib.node
- /Users/schettn/Documents/pylon/packages/pylon-server/studio-pylon/runtime/libquery_engine-darwin-arm64.dylib.node
GraphQLError: Get DMMF: Unable to resolve path to query-engine binary
Details: Could not find libquery-engine binary. Searched in:
- /Users/schettn/Documents/pylon/packages/pylon-server/studio-pylon/libquery_engine-darwin-arm64.dylib.node
- /Users/schettn/Documents/pylon/packages/pylon-server/studio-pylon/libquery_engine-darwin-arm64.dylib.node
- /Users/schettn/Documents/pylon/packages/pylon-server/libquery_engine-darwin-arm64.dylib.node
- /Users/schettn/Documents/pylon/packages/pylon-server/studio-pylon/runtime/libquery_engine-darwin-arm64.dylib.node
6 replies
PPrisma
Created by schettn on 6/19/2024 in #help-and-questions
How to cover this custom SQL with Prisma
Hi, i currently use this SQL statement to fetch data and make calculations. Is this also possible without a RAW query?
const result: {
id: string;
name: string;
distance: number;
}[] = await client.$queryRaw`
WITH MaxDistances AS (
SELECT
t.id AS trip_id,
MAX(st.distTraveled) AS max_distance
FROM
Trip t
JOIN
StopTime st ON t.id = st.tripId
GROUP BY
t.id
)
SELECT
a.id AS id,
a.name AS name,
SUM(md.max_distance) AS distance
FROM
Agency a
JOIN
Route r ON a.id = r.agencyId
JOIN
Trip t ON r.id = t.routeId
JOIN
MaxDistances md ON t.id = md.trip_id
GROUP BY
a.id
`;
const result: {
id: string;
name: string;
distance: number;
}[] = await client.$queryRaw`
WITH MaxDistances AS (
SELECT
t.id AS trip_id,
MAX(st.distTraveled) AS max_distance
FROM
Trip t
JOIN
StopTime st ON t.id = st.tripId
GROUP BY
t.id
)
SELECT
a.id AS id,
a.name AS name,
SUM(md.max_distance) AS distance
FROM
Agency a
JOIN
Route r ON a.id = r.agencyId
JOIN
Trip t ON r.id = t.routeId
JOIN
MaxDistances md ON t.id = md.trip_id
GROUP BY
a.id
`;
4 replies