mrk
mrk
Explore posts from servers
NNuxt
Created by Muhammad Awais on 8/23/2024 in #❓・help
Handling multiple modals.
Nested modals are not supported in v2, but they will be in v3. In the meantime, I created the following utility in case it helps:
export const openNested = async (callback: () => void) => {
useSlideover().close()
await new Promise(res => setTimeout(res, 1000)) // wait at least closing transition duration
callback()
}
export const openNested = async (callback: () => void) => {
useSlideover().close()
await new Promise(res => setTimeout(res, 1000)) // wait at least closing transition duration
callback()
}
then you can using e.g. as follows:
openNested(() => slideover.open(Slideover1, {
...props1,
onSubmit: async (event) => {
await openNested(() => slideover.open(Slideover2, ))
}
})
openNested(() => slideover.open(Slideover1, {
...props1,
onSubmit: async (event) => {
await openNested(() => slideover.open(Slideover2, ))
}
})
and you can chain them and use a closure to keep state of slideover 1, and pass it again once reopening it in onSubmit handler for slideover 2. The slideover components should then accept an onSubmit handler function or similar to call after being done
11 replies
NNuxt
Created by takburger on 7/12/2024 in #❓・help
Help debugging - illegal invocation rejection - nuxt hub
It might be due to invalid routeRules in nuzt.config, try commenting them out and see if that fixes it for you, it somehow did for me, though not sure what was invalid
10 replies
NNuxt
Created by takburger on 7/12/2024 in #❓・help
Help debugging - illegal invocation rejection - nuxt hub
I'm having the same issue and have not been able to find a fix... anyone? 🙏
10 replies
DTDrizzle Team
Created by mrk on 5/24/2024 in #help
UPSERT operation not working for SQLite/Turso
So this is what I ended up doing (a very slight adaptation of the example currently in the docs), simply removing the PK, "id" in this case:
const columns = [
...new Set(rows.flatMap(Object.keys))
].filter((col) => col !== pk);
const { id, ...rest } = data;
const result = await db
.insert(table)
.values({ id, ...rest })
.onConflictDoUpdate({
target: table[pk],
set: buildConflictUpdateColumns(table[pk], columns),
})
.returning();
const columns = [
...new Set(rows.flatMap(Object.keys))
].filter((col) => col !== pk);
const { id, ...rest } = data;
const result = await db
.insert(table)
.values({ id, ...rest })
.onConflictDoUpdate({
target: table[pk],
set: buildConflictUpdateColumns(table[pk], columns),
})
.returning();
with
function buildConflictUpdateColumns<
T extends SQLiteTable,
Q extends keyof T["_"]["columns"],
>(
table: T,
columns: Q[],
) {
const cls = getTableColumns(table);
return columns.reduce((acc, column) => {
const colName = cls[column].name;
acc[column] = sql.raw(`excluded.${colName}`);
return acc;
}, {} as Record<Q, SQL>);
}
function buildConflictUpdateColumns<
T extends SQLiteTable,
Q extends keyof T["_"]["columns"],
>(
table: T,
columns: Q[],
) {
const cls = getTableColumns(table);
return columns.reduce((acc, column) => {
const colName = cls[column].name;
acc[column] = sql.raw(`excluded.${colName}`);
return acc;
}, {} as Record<Q, SQL>);
}
9 replies
DTDrizzle Team
Created by mrk on 5/24/2024 in #help
UPSERT operation not working for SQLite/Turso
Thanks, makes sense! Adding it as en example would be great! I think many people might stumble with this use case. I'll try getting it to work and post the example here for the record 👍
9 replies
DTDrizzle Team
Created by mrk on 5/24/2024 in #help
UPSERT operation not working for SQLite/Turso
I also saw somewhere the possibility of doing something like the following:
const { id, ...rest } = data;
const result = await db
.insert(users)
.values({ id, ...rest })
.onConflictDoUpdate({
target: users.id,
set: rest,
})
.returning();
const { id, ...rest } = data;
const result = await db
.insert(users)
.values({ id, ...rest })
.onConflictDoUpdate({
target: users.id,
set: rest,
})
.returning();
But that wouldn't work for bulk upserts right @Mykhailo ? Which is what I'm trying to do...
9 replies
DTDrizzle Team
Created by mrk on 5/24/2024 in #help
UPSERT operation not working for SQLite/Turso
Hey! Thanks for the reply! Hmm I understand what you mean, but what I'm trying to achieve is to run an update with ALL fields EXCEPT "id" field, so not just "name"... Is that possible? That is why I was attempting to "exclude" the "id" field
9 replies
DDeno
Created by anggoran on 4/3/2024 in #help
Signals & Data Fetching
Oh I see, so it does make sense as a great place to declare shared global signals for multiple islands to import 👌 ... And yeah, after using fresh for a while, the server-client boundary is what takes the most time to get used to and requires changing one's mental model (coming from SPA's myself at least). I see how this could hugely enhance DX if signal reactivity could cross this border. Apart from frameworks looking into these patterns, there's also SignalDB which accomplishes something similar (more like a Signals-based abstraction over arbitrary databases/datastores/apis), though it's framework agnostic. Might be of interest too 👍
16 replies
DDeno
Created by anggoran on 4/3/2024 in #help
Signals & Data Fetching
Some thoughts: Would there be a reason to pass data wrapped in a signal from an async route to a client component/island? Reactivity is not carried over the wire and the server has no client/user interaction, so no need for reactivity there, right? I guess you where just answering for completeness @marvinh. , since signals are indeed serializable by fresh and sent over-the-wire. Just making sure I'm not missing out on some server signal use case 😃 This reminds me of a blogpost I read about Ryan Carniato where he hints on a future with server-to-client signals, that is, where reactivity trascends the server/client border. Maybe this could be done using WebSockets/SSE, definitively interesting...
16 replies
DDeno
Created by 177177177 on 12/7/2023 in #help
Can you make a fresh route detect, if it is being requested by `deno run`
You might be able to solve this like fresh does this for /routes/update by simply checking req.headers.get("accept"):
import { Handlers, PageProps } from "$fresh/server.ts";
import VERSIONS from "../../versions.json" assert { type: "json" };

export const handler: Handlers = {
GET(req) {
const accept = req.headers.get("accept");
let path = "/docs/concepts/updating";
if (accept && !accept.includes("text/html")) {
path = `https://deno.land/x/fresh@${VERSIONS[0]}/update.ts`;
}
return new Response(`Redirecting to ${path}`, {
headers: { "Location": path },
status: 307,
});
},
};
import { Handlers, PageProps } from "$fresh/server.ts";
import VERSIONS from "../../versions.json" assert { type: "json" };

export const handler: Handlers = {
GET(req) {
const accept = req.headers.get("accept");
let path = "/docs/concepts/updating";
if (accept && !accept.includes("text/html")) {
path = `https://deno.land/x/fresh@${VERSIONS[0]}/update.ts`;
}
return new Response(`Redirecting to ${path}`, {
headers: { "Location": path },
status: 307,
});
},
};
8 replies
DDeno
Created by mrk on 9/20/2023 in #help
Deno-native Nuxt.js?
Great idea @birkskyum !!! I hope we get there soon!
7 replies