#Mongo Atlas with Qwik without Prisma?

4 messages · Page 1 of 1 (latest)

spare oar
#

Hi all, I'm fairly new to Qwik, but have been developing for decades. I know I can use Prisma with Qwik, but is it possible to use mongo (Atlas) directly, like you can in node? I want to be able to use Atlas' new vector search. I can't find anything about it, like where I would set up the connection etc.

I'm using the netlify-edge addon

spare oar
#

Mongo Atlas with Qwik without Prisma?

shadow osprey
#

You definitely don't need Prisma. I managed to get Qwik to work with Mongo locally, however there are issues with the mongo library if you try to deploy on edge.
Here is a template:
https://github.com/kerbelp/Qwik-MongoDB-Vercel

If you have a native Node backend then it should work.

GitHub

A Starter for a project with Qwik+MongoDB+Vercel. Contribute to kerbelp/Qwik-MongoDB-Vercel development by creating an account on GitHub.

spare oar
#

ah, thanks!

I've been playing around locally (so not deployed to Netlify yet) and I've put this in my root layout.tsx and it seems to only run this code once and runs it from any route, but only one which is what I'm looking for. I'll check out your repo there. Much appreciated

layout.tsx

import { MongoClient } from 'mongodb'

const client = new MongoClient(process.env.DATABASE_URL ? process.env.DATABASE_URL : 'mongodb://localhost:27017')
await client.connect();
console.log('Connected to MongoDB', client);

const databasesList = await client.db().admin().listDatabases();
console.log('Databases:', databasesList);