-
tags: [sveltekit,sequelize]
|
Beta Was this translation helpful? Give feedback.
Answered by
jeblister
Mar 15, 2023
Replies: 1 comment
-
Here's an example of how to use Sequelize with SvelteKit hooks, using the Sveltekit documentation:
Here's an example of what the code might look like: import { Sequelize } from 'sequelize';
const sequelize = new Sequelize({
dialect: 'mysql',
host: 'localhost',
username: 'root',
password: 'password',
database: 'mydatabase',
});
export async function handle({ event, resolve }) {
const results = await sequelize.query('SELECT * FROM mytable');
event.locals.myData = results[0];
return resolve(request);
} This hook function queries the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jeblister
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example of how to use Sequelize with SvelteKit hooks, using the Sveltekit documentation:
hooks.server.js
.Here's an example of what the code might look like: