michael
michael
Explore posts from servers
DTDrizzle Team
Created by michael on 3/25/2024 in #help
Help with a complicated statement.
This is my first time using SQL, I would like help with how I should write the statement to get my data in the desired format. For example I have this schema:
export const links = sqliteTable('links', {
slug: text('slug').primaryKey(),
url: text('url').notNull(),
clicks: integer('clicks').notNull().default(0)
});

export const publicLinks = sqliteTable('public_links', {
id: integer('id').primaryKey(),
name: text('name').notNull(),
fill: text('fill').notNull(),
background: text('background').notNull(),
path: text('path').notNull()
});

export const publicLinkEntries = sqliteTable('public_link_entries', {
id: integer('id').primaryKey(),
linkId: integer('link_id')
.notNull()
.references(() => publicLinks.id),
slug: text('slug')
.notNull()
.references(() => links.slug),
title: text('title').notNull(),
subtitle: text('subtitle').notNull()
});
export const links = sqliteTable('links', {
slug: text('slug').primaryKey(),
url: text('url').notNull(),
clicks: integer('clicks').notNull().default(0)
});

export const publicLinks = sqliteTable('public_links', {
id: integer('id').primaryKey(),
name: text('name').notNull(),
fill: text('fill').notNull(),
background: text('background').notNull(),
path: text('path').notNull()
});

export const publicLinkEntries = sqliteTable('public_link_entries', {
id: integer('id').primaryKey(),
linkId: integer('link_id')
.notNull()
.references(() => publicLinks.id),
slug: text('slug')
.notNull()
.references(() => links.slug),
title: text('title').notNull(),
subtitle: text('subtitle').notNull()
});
I would like a statement to return the data in this format:
[
{
"name": "...",
"fill": "...",
"background": "...",
"path": "...",
"clicks": 5,
"links": [
{
"slug": "...",
"title": "...",
"subtitle": "..."
}
]
}
]
[
{
"name": "...",
"fill": "...",
"background": "...",
"path": "...",
"clicks": 5,
"links": [
{
"slug": "...",
"title": "...",
"subtitle": "..."
}
]
}
]
The most important part, where "clicks" is the sum of clicks from each slug from each entry of each public link. If that makes sense.
2 replies
SSolidJS
Created by michael on 12/31/2023 in #support
How to wait for the value from a useAction?
I am using useAction with a server action, but when I call the action it is returning a Promise, how do I wait for the Promise and display the result?
7 replies
SSolidJS
Created by michael on 12/31/2023 in #support
How to define layout for index page?
I am looking to define a shared layout for some pages, according to the docs it seems like you would do something like this, and it does work if you are navigating manually to the page, but clicking links to the pages show an error "Failed to fetch dynamically imported module" where its trying to find "/routes/about.tsx" instead of "routes/(home)/about.tsx" Is this a bug, or is there is another way to do it?
17 replies
SSolidJS
Created by michael on 12/30/2023 in #support
How to set size of child element?
I have this component:
export function NavigationBarItem(props: { icon: JSX.Element }) {
return <div class="m-4 h-8 w-8">{props.icon}</div>;
}
export function NavigationBarItem(props: { icon: JSX.Element }) {
return <div class="m-4 h-8 w-8">{props.icon}</div>;
}
How do I set the icons size?
4 replies