nuxt-mongodb
TypeScript icon, indicating that this package has built-in type declarations

1.0.13 • Public • Published

Nuxt MongoDB

A simple way to use mongoDB in your Nuxt 3 project.

Usage

Install the module:

npm i -D nuxt-mongodb

Add nuxt-mongodb in the modules array in nuxt.config.ts:

export default defineNuxtConfig({
  modules: ['nuxt-mongodb'],
})

Add your mongo connection string and main database name in your .env file:

MONGO_CONNECTION_STRING={{your_mongo_connection_string}}
MONGO_DB={{your_mongo_db_name}}

When you start your project, mongo will connect and you can use it like this:

import { mongo } from '#nuxt-mongodb'

const db = mongo.db()
const response = await db.collection('YOUR_COLLECTION').find()

/nuxt-mongodb/

    Package Sidebar

    Install

    npm i nuxt-mongodb

    Weekly Downloads

    63

    Version

    1.0.13

    License

    MIT

    Unpacked Size

    6.74 kB

    Total Files

    13

    Last publish

    Collaborators

    • tim103