bombillazo
bombillazo
Explore posts from servers
KKysely
Created by bombillazo on 9/26/2024 in #help
Kysely client usage and pooling question
Hello, We have a long running server that at the moment creates a single Kysely instance. It is setup to use pg pooling. We have a util function called getKysely which returns this instance and is used throught our backend , like on every request handler that calls the DB. So in theory multiple concurrent requests call this function to get the Kysely client and make queries. We are noticing that even within the same API endpoint handler, executing queries with a fetched client seems to be running on different connections. We think this because we sometimes execute raw sql queries which change the role of the connection, but later on using the same client we execute a query to check the current role and it is not the one set up previously. I am curious about how Kysely internally uses pooling, does it fetch a connection from the pool on every query? I know we are using a singleton, but how can I make sure that Kysely uses a single connection throughout the scope of a single request?
7 replies
HHono
Created by bombillazo on 8/22/2024 in #help
Cannot load `hono` from JSR
Hello, we're using Deno and are getting the following error when importing hono using the jsr:@hono/hono import which has worked for us for the past months:
import 'https://registry-staging.deno.com/@hono/hono/meta.json' failed: error sending request for url (https://registry-staging.deno.com/@hono/hono/meta.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided
import 'https://registry-staging.deno.com/@hono/hono/meta.json' failed: error sending request for url (https://registry-staging.deno.com/@hono/hono/meta.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided
Any way to fix this issue?
2 replies
DDeno
Created by bombillazo on 8/13/2024 in #help
Reset position of terminal cursor when calling io.writeAllSync()
Currently using io.writeAllSync, the next data is written where the last data left off, even with a new line the cursor is kept horizontally in the position that was left. I tried the ansi library cursorBack function but it did not work, how can I control or reset the cursor?
2 replies
DDeno
Created by bombillazo on 8/13/2024 in #help
How to log Deno.Command output in real time (not after command completes)
Hello, is there a guide on how to log stdout with a Deno.Command is running, not just after it completes?
6 replies
HHono
Created by bombillazo on 8/11/2024 in #help
Return early from middleware
Hello, I want to return a 200 response from a middleware if certain conditions are not met, else run await and cleanup after the await. How can I return early from the middleare function?
3 replies
HHono
Created by bombillazo on 8/8/2024 in #help
Match both `/` and `/:id` routes the the same router
Hello, is there any way to handle 2 routes in the same router? We want to handle requests coming to both / and /:id to handle when id is undefined or has a value.
6 replies
DDeno
Created by bombillazo on 7/3/2024 in #help
Is there any way to force a Deno dependency to use a specific version of std?
We're having an issue were a dependency we are importing from npm with the npm: identifier is trying to use a node lib that only exisits up to std v0.177.0, specifically the tty lib. Our main std version is in 0.244.0 specified in our import_map.json file. Is there any way to specify this 3rd party dep to use the std version it requires to work?
2 replies
KKysely
Created by bombillazo on 6/20/2024 in #help
How to do `LIKE ANY` query in Kysely?
Hello, I am trying to build this query in Kysely but have no idea how to properly insert the ANY into the query.
SELECT *
FROM your_table
WHERE your_column LIKE ANY (ARRAY[
'%suffix1',
'%suffix2',
'%suffix3'
]);
SELECT *
FROM your_table
WHERE your_column LIKE ANY (ARRAY[
'%suffix1',
'%suffix2',
'%suffix3'
]);
Any constructs with kysely that I should use in particular?
3 replies
KKysely
Created by bombillazo on 5/17/2024 in #help
Dynamic conditional raw query question
Hello there, Im trying to create a dynamic query like this:
await sql`SELECT
column AS "data"
FROM my_table
${type ? ` WHERE type = ${type}` : ''};`.execute(client);
await sql`SELECT
column AS "data"
FROM my_table
${type ? ` WHERE type = ${type}` : ''};`.execute(client);
But kysely is trying to do substitution where I have my TS logic to either add the WHERE clause or not. How can I fix this ?
6 replies
DDeno
Created by bombillazo on 4/11/2024 in #help
How to upgrade `import_map.json` package versions?
Hello, in node I used ncu to check for new package versions and automatically update the versions. Is there any utility for deno to scna my packages and check if there are new versions?
4 replies
KKysely
Created by bombillazo on 4/11/2024 in #help
jsonArrayFrom with `as` not being typed
I have the following query
await db
.selectFrom('user')
.selectAll()
.select((eb) => [
jsonArrayFrom(
eb
.selectFrom('book')
.selectAll()
.where('book.is_enabled', '=', true)
).as('books'),
])
.execute();
await db
.selectFrom('user')
.selectAll()
.select((eb) => [
jsonArrayFrom(
eb
.selectFrom('book')
.selectAll()
.where('book.is_enabled', '=', true)
).as('books'),
])
.execute();
but the resulting query is not seeing the jsonArrayFrom field with the name books , rather it types it like this:
{
[x: string]: {
created_at: TimestampTZ;
description: string | null;
id: string;
label: string | null;
name: string;
is_enabled: boolean;
}[];
... 5 more ...;
name: string;
}[]
{
[x: string]: {
created_at: TimestampTZ;
description: string | null;
id: string;
label: string | null;
name: string;
is_enabled: boolean;
}[];
... 5 more ...;
name: string;
}[]
How can i fix this?
25 replies
KKysely
Created by bombillazo on 4/2/2024 in #help
Kysely setup in monolith API
Hello, we have a basic http server with a basic router and a PostgreSQL database. We're wondering what is the proper setup to use the Kysely client in our routes to make calls to the database. Should there be a singleton client that is used across routes, or do we need to instantiate a kysely client on every request ?
10 replies
KKysely
Created by bombillazo on 2/9/2024 in #help
How do I use `WHERE NOT EXISTS`?
I am trying to write the followng where condition:
INSERT INTO Filing (location_id, filing_date, other_columns)
SELECT L.location_id, '2023-01-01'::date, default_values_for_other_columns
FROM Location L
WHERE NOT EXISTS (
SELECT 1
FROM Filing F
WHERE F.location_id = L.location_id
AND F.filing_date = '2023-01-01'::date
);
INSERT INTO Filing (location_id, filing_date, other_columns)
SELECT L.location_id, '2023-01-01'::date, default_values_for_other_columns
FROM Location L
WHERE NOT EXISTS (
SELECT 1
FROM Filing F
WHERE F.location_id = L.location_id
AND F.filing_date = '2023-01-01'::date
);
But Im not sure how to approach it.
5 replies
DDeno
Created by bombillazo on 1/31/2024 in #help
Run `nvm` using Deno.Command
Hello, I am trying to run nvm from a Deno script using Deno.Command.
new Deno.Command('nvm', {
args: ['use'],
stderr: 'inherit',
stdin: 'inherit',
stdout: 'piped',
}).outputSync;
new Deno.Command('nvm', {
args: ['use'],
stderr: 'inherit',
stdin: 'inherit',
stdout: 'piped',
}).outputSync;
but I am getting the following error:
Failed to spawn 'nvm': No such file or directory (os error 2)
Failed to spawn 'nvm': No such file or directory (os error 2)
nvm was install with brew and I tried passing env: {PATH: Deno.env.get('PATH') but nothing works...
2 replies
KKysely
Created by bombillazo on 1/25/2024 in #help
Examples inner join using OR?
Hello, we are having trouble trying to have a inner join using OR, as in ON a.id = b.id OR a.sub_id = b.sub_id
5 replies
KKysely
Created by bombillazo on 1/18/2024 in #help
Omit/filter out columns from query
Hey, is there an easy or convenient way with Kysely to filter out data from a query? Lets say I have columns 1,2,3,4,..., 10 and I want to omit column 9, do I have to really list all my columns like this:
select(['1','2','3','4','5','6','7','8','10']
select(['1','2','3','4','5','6','7','8','10']
?
11 replies
KKysely
Created by bombillazo on 1/17/2024 in #help
How to create a typed array of columns for select?
Hello, I am trying to create some helpers that contain the list of columns used by multiple queries, and I want to have them typed to the table they belong to to have it suggest errors if a table changes or someone uses a non-valid column. How is this achievable with the kysely helper types? The array may also include expression builder or the jsonObjectFrom helpers since they are valid Select options
3 replies
KKysely
Created by bombillazo on 1/12/2024 in #help
Return `null` by default if no record found
Hey, I am looking to have my queries return null instead of undefined if no records match my query when using executeTakeFirst. Is there a way to set this in the Kysely client?
7 replies
DDeno
Created by bombillazo on 12/25/2023 in #help
Deno.Command output as it runs
Hello, I am trying to run a command and have its output be logged as it runs , but for some reason the command runs but no output is displayed. I tried using both ouput with await and outputSync, setting stdout to piped and inherit but nothing.
6 replies
RRefine
Created by fair-rose on 12/14/2023 in #ask-any-question
What are the differences between the `useNotification` and `useHandleNotification` hooks?
Id like to know more about each hook and what are their different uses and purposes.
4 replies