NubeBuster
NubeBuster
Explore posts from servers
TTCTheo's Typesafe Cult
Created by NubeBuster on 5/30/2024 in #questions
Queryraw condition joining in Prisma
I added a playground for you to explore and experiment with this issue https://github.com/Nubebuster/prisma-raw
7 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
I added a playground for you to explore and experiment with this issue https://github.com/Nubebuster/prisma-raw
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Bump
10 replies
TTCTheo's Typesafe Cult
Created by NubeBuster on 5/30/2024 in #questions
Queryraw condition joining in Prisma
Bump
7 replies
TTCTheo's Typesafe Cult
Created by NubeBuster on 5/30/2024 in #questions
Queryraw condition joining in Prisma
Bump
7 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Bump
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Bump
10 replies
TTCTheo's Typesafe Cult
Created by NubeBuster on 5/30/2024 in #questions
Queryraw condition joining in Prisma
Bump
7 replies
TTCTheo's Typesafe Cult
Created by NubeBuster on 5/30/2024 in #questions
Queryraw condition joining in Prisma
const conditions = [];
const params = [];

// Add bookingCount condition if it exists
if (bookingCount !== undefined) {
conditions.push(`bookingCount > ?`);
params.push(`${bookingCount}`);
}

// Add zipCodeLike conditions if they exist
if (Array.isArray(zipCodeLike) && zipCodeLike.length > 0) {
const zipConditions = zipCodeLike
.map(() => `recentZIPCode LIKE ?`)
.join(" OR ");
conditions.push(`(${zipConditions})`);
params.push(...zipCodeLike);
}

// Combine all conditions into a single WHERE clause
let whereClause = "";
if (conditions.length > 0) {
whereClause = `SELECT * FROM #TempResults WHERE ${conditions.join(" AND ")}`;
}
console.log("TTT", whereClause, params);

const query = Prisma.sql([whereClause, ...params]);
const conditions = [];
const params = [];

// Add bookingCount condition if it exists
if (bookingCount !== undefined) {
conditions.push(`bookingCount > ?`);
params.push(`${bookingCount}`);
}

// Add zipCodeLike conditions if they exist
if (Array.isArray(zipCodeLike) && zipCodeLike.length > 0) {
const zipConditions = zipCodeLike
.map(() => `recentZIPCode LIKE ?`)
.join(" OR ");
conditions.push(`(${zipConditions})`);
params.push(...zipCodeLike);
}

// Combine all conditions into a single WHERE clause
let whereClause = "";
if (conditions.length > 0) {
whereClause = `SELECT * FROM #TempResults WHERE ${conditions.join(" AND ")}`;
}
console.log("TTT", whereClause, params);

const query = Prisma.sql([whereClause, ...params]);
TTT SELECT * FROM #TempResults WHERE bookingCount > ? AND (recentZIPCode LIKE ? OR recentZIPCode LIKE ?) [ '2', '22%', '21%' ] ⨯ TypeError: Expected 4 strings to have 3 values
7 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Is this impossible?
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
Bump
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
What does "Expected 4 strings to have 3 values" even mean...?
10 replies
PPrisma
Created by NubeBuster on 5/28/2024 in #help-and-questions
Queryraw condition joining
const conditions = [];
const params = [];

// Add bookingCount condition if it exists
if (bookingCount !== undefined) {
conditions.push(`bookingCount > ?`);
params.push(`${bookingCount}`);
}

// Add zipCodeLike conditions if they exist
if (Array.isArray(zipCodeLike) && zipCodeLike.length > 0) {
const zipConditions = zipCodeLike
.map(() => `recentZIPCode LIKE ?`)
.join(" OR ");
conditions.push(`(${zipConditions})`);
params.push(...zipCodeLike);
}

// Combine all conditions into a single WHERE clause
let whereClause = "";
if (conditions.length > 0) {
whereClause = `SELECT * FROM #TempResults WHERE ${conditions.join(" AND ")}`;
}
console.log("TTT", whereClause, params);

const query = Prisma.sql([whereClause, ...params]);
const conditions = [];
const params = [];

// Add bookingCount condition if it exists
if (bookingCount !== undefined) {
conditions.push(`bookingCount > ?`);
params.push(`${bookingCount}`);
}

// Add zipCodeLike conditions if they exist
if (Array.isArray(zipCodeLike) && zipCodeLike.length > 0) {
const zipConditions = zipCodeLike
.map(() => `recentZIPCode LIKE ?`)
.join(" OR ");
conditions.push(`(${zipConditions})`);
params.push(...zipCodeLike);
}

// Combine all conditions into a single WHERE clause
let whereClause = "";
if (conditions.length > 0) {
whereClause = `SELECT * FROM #TempResults WHERE ${conditions.join(" AND ")}`;
}
console.log("TTT", whereClause, params);

const query = Prisma.sql([whereClause, ...params]);
TTT SELECT * FROM #TempResults WHERE bookingCount > ? AND (recentZIPCode LIKE ? OR recentZIPCode LIKE ?) [ '2', '22%', '21%' ] ⨯ TypeError: Expected 4 strings to have 3 values
10 replies
TTCTheo's Typesafe Cult
Created by NubeBuster on 7/30/2023 in #questions
How does vercel run my code? Is my cache code working as intended?
I was caching the fetch data in the api route so that clients can request that data from a third party from my api. This should not be done. I used getStaticProps with revalidate to put the data into the page which means no additional request is needed.
export async function getStaticProps() {
const objects = await getObjects();

return {
props: {
objects,
},
revalidate: 600,
};
}
export async function getStaticProps() {
const objects = await getObjects();

return {
props: {
objects,
},
revalidate: 600,
};
}
This solves the issue and even improves the general logic.
3 replies
TTCTheo's Typesafe Cult
Created by NubeBuster on 6/24/2023 in #questions
Continuous process while server is running
ChatGPT Great answer
6 replies
TTCTheo's Typesafe Cult
Created by NubeBuster on 6/24/2023 in #questions
Continuous process while server is running
I just had some shower thoughts: NextJS is supposed to be horizontally scalable. Therefore running an instance manager on the NextJS backend makes no sense. I would have to make a third server application that the frontend can call for instance statusses and screenshots. Correct me if I'm wrong
6 replies