A bit of a short day, I had to make a fence to block the dog from eating compost.
Trying to answer a stupid question. Where can I put a var that represents the db so it is accessible by everyone? Without this I'd have to spin up and shutdown a db connection with each request.
The flagship example sidesteps this by calling an external 'api' url.
I guess that would be connection pooling. But the question remains.
Was able to solve it using https://github.com/sveltejs/kit/issues/1538#issuecomment-848002582
Basically create a promise in hooks.server.ts and that promise will run only once, so it will function like a global var. Then stick it into events.local and it will be accessible in the rest of the app.
But it turns out that the mongodb nodejs driver already implements a connection pool, so I problably won't need a global variable (for that anyway). Nice to know though.
I think from here on out, most status updates are going to be about pretty trivial things. When the rubber hits the road, it's the silly little things that take the most time, especially when you are getting up to speed with a language.
(post is archived)