The function getName is successfully retrieving the name of the person with id 1 from the database, but there seems to be an issue as this code is not logging anything to the console, not even the debug console.log("running"):
import { Database } from '~/types';
import { Kysely, PostgresDialect } from 'kysely';
import pkg from 'pg';
import { createEffect, createSignal } from 'solid-js';
const { Pool } = pkg;
const dialect = new PostgresDialect({
pool: new Pool({
database: 'db',
host: 'fakehost',
user: 'user',
port: 5432,
max: 10,
ssl: true,
password: 'password123',
}),
});
const db = new Kysely<Database>({
dialect,
});
async function getName(id: number) {
const x = await db.selectFrom('person').selectAll().where("id" , "=" , id).execute();
await console.log(x[0].first_name) //does not execute or show anything
return x[0].first_name;
}
export default function Myperson() {
//getName(1) runs and log to the console 'Jhon' successfully but
const [name , setName] = createSignal('Loading...')
createEffect(() => {
(async () => {
console.log("Running") //does not execute or show anything
const nameResult = await getName(1);
setName(nameResult);
})();
});
return (
<div>
{name()}
</div>
);
}