theart4290
theart4290
TTCTheo's Typesafe Cult
Created by Lopen on 9/1/2023 in #questions
should i use a pool or connection in mysql
lgtm, give it a go
26 replies
TTCTheo's Typesafe Cult
Created by rustclan on 9/3/2023 in #questions
TRPC error handling
You can specify predefined error codes and display some user friendly message for each of them. The actual error message could be somewhere in your internal logs
4 replies
TTCTheo's Typesafe Cult
Created by Lopen on 9/1/2023 in #questions
should i use a pool or connection in mysql
Have a look at the docs
async function main() {
// get the client
const mysql = require('mysql2');
// create the pool
const pool = mysql.createPool({host:'localhost', user: 'root', database: 'test'});
// now get a Promise wrapped instance of that pool
const promisePool = pool.promise();
// query database using promises
const [rows,fields] = await promisePool.query("SELECT 1");
}
async function main() {
// get the client
const mysql = require('mysql2');
// create the pool
const pool = mysql.createPool({host:'localhost', user: 'root', database: 'test'});
// now get a Promise wrapped instance of that pool
const promisePool = pool.promise();
// query database using promises
const [rows,fields] = await promisePool.query("SELECT 1");
}
https://www.npmjs.com/package/mysql2
26 replies
TTCTheo's Typesafe Cult
Created by Omar-7ioo on 9/1/2023 in #questions
Zod overrides react-hook-form validation
Sounds like you want to run some manual validations first and then parse it with a stricter zod schema. Is that the case? Alternatively you could make it required initially and then handle parsing errors however you want.
8 replies
TTCTheo's Typesafe Cult
Created by Lopen on 9/1/2023 in #questions
should i use a pool or connection in mysql
as mentioned above, use a connection pool, but make sure you close unused connections (prisma does it for you btw). If you initialise a separate connection for each request, it will makes things not only painfully slow, but also might crash your db
26 replies