Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timb-103/nuxt-mongodb
A simple way to use mongoDB in your Nuxt 3 project.
https://github.com/timb-103/nuxt-mongodb
mongodb nuxt nuxt3
Last synced: 2 months ago
JSON representation
A simple way to use mongoDB in your Nuxt 3 project.
- Host: GitHub
- URL: https://github.com/timb-103/nuxt-mongodb
- Owner: timb-103
- Created: 2023-07-24T23:15:02.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-07T05:13:05.000Z (over 1 year ago)
- Last Synced: 2024-10-13T21:54:30.208Z (3 months ago)
- Topics: mongodb, nuxt, nuxt3
- Language: TypeScript
- Homepage:
- Size: 538 KB
- Stars: 22
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nuxt MongoDB
A simple way to use mongoDB in your Nuxt 3 project.
## Usage
Install the module:
```sh
npm i -D nuxt-mongodb
```Add `nuxt-mongodb` in the `modules` array in `nuxt.config.ts`:
```js
export default defineNuxtConfig({
modules: ['nuxt-mongodb'],
})
```Add your mongo connection string and main database name in your `.env` file:
```env
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:
```js
import { mongo } from '#nuxt-mongodb'const db = mongo.db()
const response = await db.collection('YOUR_COLLECTION').find()
```