CODY
CODY
Explore posts from servers
NNuxt
Created by CODY on 3/25/2024 in #❓・help
How to get correct type of $attrs/useAttrs?
No description
2 replies
DTDrizzle Team
Created by CODY on 12/23/2023 in #help
Can I .prepare() a transaction?
Surprisingly I can call prepare inside transaction callback but it doesn't make sense to me since we usually using prepare() as a variable out of block scope.
await db.transaction(async (tx) => {
const q1 = tx.update(...).set(...).where(...).prepare();
const q2 = tx.insert(...).values(...).prepare();

await q1.execute();
await q2.execute();
});
await db.transaction(async (tx) => {
const q1 = tx.update(...).set(...).where(...).prepare();
const q2 = tx.insert(...).values(...).prepare();

await q1.execute();
await q2.execute();
});
5 replies
TTCTheo's Typesafe Cult
Created by CODY on 7/8/2023 in #questions
How can I make node.js package that have a custom command?
Like "npm", "next", "prisma", "drizzle", etc. things whenever you start a command. How do I find terms/keywords to implement this.
1 replies
TTCTheo's Typesafe Cult
Created by CODY on 2/18/2023 in #questions
Type a function based on its argument value.
I have a function that takes an object and a boolean (default to false). It will return an array of object with key id only if parameter bool of the function set to true.
const helpMeTypeThis = (obj: MyObj, bool = false)
: {id?: string | undefinded, [key: string]: any }[] => {
return obj.map(...)
}

helpMeTypeThis(obj) // => { [key: string]: any }
helpMeTypeThis(obj, false) // => { [key: string]: any }
helpMeTypeThis(obj, true) // => { id: string, [key: string]: any }
const helpMeTypeThis = (obj: MyObj, bool = false)
: {id?: string | undefinded, [key: string]: any }[] => {
return obj.map(...)
}

helpMeTypeThis(obj) // => { [key: string]: any }
helpMeTypeThis(obj, false) // => { [key: string]: any }
helpMeTypeThis(obj, true) // => { id: string, [key: string]: any }
2 replies
TTCTheo's Typesafe Cult
Created by CODY on 2/13/2023 in #questions
How to fix env types on `schema.mjs`?
3 replies