You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Application}from"https://deno.land/x/oak/mod.ts";import{api}from"./api.ts";import{db}from"./data/Database.ts";constport=8080;constapp=newApplication();// Init DBawaitdb.sync();// Middlewareapp.use(logger);// Routesapp.use(api.routes());// Close dbdb.close()app.addEventListener("listen",()=>{console.log(`⚡️⚡️⚡️ Listening on localhost:${port}`);});awaitapp.listen({ port });
From this I always got a server error. But when I leave db.close() away the the app is running without problems.
import{Application}from"https://deno.land/x/oak/mod.ts";import{api}from"./api.ts";import{db}from"./data/Database.ts";constport=8080;constapp=newApplication();// Init DBawaitdb.sync();// Middlewareapp.use(logger);// Routesapp.use(api.routes());app.addEventListener("listen",()=>{console.log(`⚡️⚡️⚡️ Listening on localhost:${port}`);});awaitapp.listen({ port });
I also saw a tutorial where the db.sync() call was moved below the routes like in the snippet below. Also this works fine.
import{Application}from"https://deno.land/x/oak/mod.ts";import{api}from"./api.ts";import{db}from"./data/Database.ts";constport=8080;constapp=newApplication();// Middlewareapp.use(logger);// Routesapp.use(api.routes());// Init DBawaitdb.sync();app.addEventListener("listen",()=>{console.log(`⚡️⚡️⚡️ Listening on localhost:${port}`);});awaitapp.listen({ port });
At the moment I'm not able to figure out what's the right way and I'm also strugging with this call to db.sync(). I really want to know it is necessary and if yes where to put it and why.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there,
I'm new to Deno and use Denodb with Sqlite for a small side project - https://github.com/dpointeck/dag.
I really like Denodb it has a nice API. I started out with this server.ts.
From this I always got a server error. But when I leave db.close() away the the app is running without problems.
I also saw a tutorial where the db.sync() call was moved below the routes like in the snippet below. Also this works fine.
At the moment I'm not able to figure out what's the right way and I'm also strugging with this call to db.sync(). I really want to know it is necessary and if yes where to put it and why.
Beta Was this translation helpful? Give feedback.
All reactions