Mads
Mads
Explore posts from servers
DTDrizzle Team
Created by Mads on 8/31/2024 in #help
notNull and Unique
Hi Whenever I use push:db I get that I am about to add a new unique constraint. I then checked and I don’t actually have the unique constraints set. Am I doing something wrong?
export const companies = mysqlTable('companies', {
id: int('id').autoincrement().primaryKey(),
name: varchar('name', { length: 255 }).unique().notNull(),
owner_id: varchar('owner_id', { length: 255 }).notNull().references(() => users.id),
has_finished_introduction: boolean('has_finished_introduction').default(false).notNull(),
created_at: datetime('created_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
updated_at: datetime('updated_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
})
export const companies = mysqlTable('companies', {
id: int('id').autoincrement().primaryKey(),
name: varchar('name', { length: 255 }).unique().notNull(),
owner_id: varchar('owner_id', { length: 255 }).notNull().references(() => users.id),
has_finished_introduction: boolean('has_finished_introduction').default(false).notNull(),
created_at: datetime('created_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
updated_at: datetime('updated_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
})
"drizzle-kit": "^0.24.2",
7 replies
NNuxt
Created by Mads on 5/7/2024 in #❓・help
Any way to trigger a Nitro Task from an endpoint?
Is it possible to hit an endpoint to trigger a Nitro Task?
2 replies
NNuxt
Created by Mads on 7/20/2023 in #❓・help
Layer Extend broken on Vercel
No description
25 replies
NNuxt
Created by Mads on 5/23/2023 in #❓・help
build failed vercel
No description
13 replies
NNuxt
Created by Mads on 4/24/2023 in #❓・help
Arrays in query params
Hi! Is there a simple way to navigate to a link with query params as array? e.g. this link results in /checkout?product_id=5&equipment_ids=30&equipment_ids=31 Which is fine for me, as I can easily get it working. However, Facebook does not like this and strips away the duplicate equipments_ids. It always keeps the last one.
<NuxtLink
:to="{
path: '/checkout',
query: {
product_id: params.product_id,
equipment_ids: [30, 31],
},
}"
>
Click me
</NuxtLink>
<NuxtLink
:to="{
path: '/checkout',
query: {
product_id: params.product_id,
equipment_ids: [30, 31],
},
}"
>
Click me
</NuxtLink>
1 replies
NNuxt
Created by Mads on 3/28/2023 in #❓・help
Multiply return types
When having an API and there is multiple return scenarios. e.g.
export default defineEventHandler(async (event) => {
const { isactive } = getQuery(event) as {
isactive?: string;
};

if (isactive === "true") {
return {
isactive: true,
};
} else {
return {
hello: "world",
};
}
});
export default defineEventHandler(async (event) => {
const { isactive } = getQuery(event) as {
isactive?: string;
};

if (isactive === "true") {
return {
isactive: true,
};
} else {
return {
hello: "world",
};
}
});
How can I on the frontend determine and use types based on the result? I was hoping something like this would work:
<template>
<div>
<div v-if="response.hello">
<!-- Make types work here -->
{{ response.hello }}
</div>

<div v-if="response.isactive">
<!-- Make types work here -->
{{ response.isactive }}
</div>
</div>
</template>
<template>
<div>
<div v-if="response.hello">
<!-- Make types work here -->
{{ response.hello }}
</div>

<div v-if="response.isactive">
<!-- Make types work here -->
{{ response.isactive }}
</div>
</div>
</template>
The error i'm getting is something like:
Property 'hello' does not exist on type 'SerializeObject<...
Property 'hello' does not exist on type 'SerializeObject<...
48 replies
NNuxt
Created by Mads on 3/10/2023 in #❓・help
When prerendering why are there still network requests?
I am prerendering a bunch of pages:
nitro: {
prerender: {
crawlLinks: true,
routes: ["/"],
ignore: ["/tak", "/konfiguration", "/checkout"],
},
}
nitro: {
prerender: {
crawlLinks: true,
routes: ["/"],
ignore: ["/tak", "/konfiguration", "/checkout"],
},
}
Why are my useFetch calls still running? Shouldn't the site be statically generated?
7 replies
NNuxt
Created by Mads on 1/4/2023 in #❓・help
Pre-render page but SSR when query string
Hi I'd like to build a page where I pre-render a page. Let's call it /blog. I then put the following settings in the Nuxt config like this:
nitro: {
prerender: {
crawlLinks: true,
routes: ["/"],
},
}
nitro: {
prerender: {
crawlLinks: true,
routes: ["/"],
},
}
This works perfectly and /blog is now pre-rendered. However, if I do something like this /blog?author=James it also works well and the page now displays values and it basically becomes a SPA, meaning the content of the page is not pre-rendered. What i'd like instead of it becoming a SPA, which means when JS is disabled it shows the page equal to /blog and not /blog?author=James, is for it to render with SSR. Thus, when navigating to /blog should be a pre-rendered page and /blog?author=James should be a server side rendered page. Is this at all possible?
3 replies