9 Commits

Author SHA1 Message Date
9b63877eaa chore(release): v1.0.2 2023-10-04 05:13:46 +03:00
ba845931da chore(release): v1.0.2 2023-10-04 05:11:40 +03:00
3d7503e227 chore: lint 2023-10-03 19:56:52 -06:00
c570597d06 fix: resolve build stuck issue with nitro pre-render enabled (#26) 2023-10-04 04:56:15 +03:00
e7c7beb8fd docs: default connection
close #24
2023-10-03 03:46:23 +03:00
037920620e chore(release): v1.0.1 2023-09-22 01:50:58 +03:00
0f73464afe chore: update dependencies 2023-09-21 16:41:21 -06:00
5bf554fbdf chore(release): v1.0.1 2023-09-20 20:19:25 +03:00
b566196c96 chore(release): v1.0.0 2023-09-20 19:54:06 +03:00
5 changed files with 2545 additions and 452 deletions

View File

@ -1,6 +1,40 @@
# Changelog # Changelog
## v1.0.2
[compare changes](https://github.com/arashsheyda/nuxt-mongoose/compare/v1.0.1...v1.0.2)
### 🩹 Fixes
- Resolve build stuck issue with nitro pre-render enabled ([#26](https://github.com/arashsheyda/nuxt-mongoose/pull/26))
### 📖 Documentation
- Default connection ([e7c7beb](https://github.com/arashsheyda/nuxt-mongoose/commit/e7c7beb))
### 🏡 Chore
- **release:** V1.0.2 ([ba8459](https://github.com/arashsheyda/nuxt-mongoose/commit/ba8459))
- Lint ([3d7503e](https://github.com/arashsheyda/nuxt-mongoose/commit/3d7503e))
### ❤️ Contributors
- Arash Sheyda <sheidaeearash1999@gmail.com>
- Arash
## v1.0.1
### 🏡 Chore
- **release:** V1.0.0 ([b566196](https://github.com/arashsheyda/nuxt-mongoose/commit/b566196))
- **release:** V1.0.1 ([5bf554f](https://github.com/arashsheyda/nuxt-mongoose/commit/5bf554f))
- Update dependencies ([0f73464](https://github.com/arashsheyda/nuxt-mongoose/commit/0f73464))
### ❤️ Contributors
- Arash Sheyda <sheidaeearash1999@gmail.com>
## v1.0.0 ## v1.0.0
[compare changes](https://github.com/arashsheyda/nuxt-mongoose/compare/v0.0.9...v1.0.0) [compare changes](https://github.com/arashsheyda/nuxt-mongoose/compare/v0.0.9...v1.0.0)

View File

@ -54,7 +54,12 @@ This function creates a new Mongoose model with schema. Example usage:
| `hooks` | [`(schema: Schema<T>) => void`](https://mongoosejs.com/docs/middleware.html) | false | Schema Hooks Function to customize Model | | `hooks` | [`(schema: Schema<T>) => void`](https://mongoosejs.com/docs/middleware.html) | false | Schema Hooks Function to customize Model |
::alert
you can access the default connection with importing it from mongoose:
::
```
import { connection } from 'mongoose'
```
## `defineMongooseConnection` ## `defineMongooseConnection`
This function creates a new Mongoose connection. This function creates a new Mongoose connection.

View File

@ -1,7 +1,7 @@
{ {
"name": "nuxt-mongoose", "name": "nuxt-mongoose",
"type": "module", "type": "module",
"version": "1.1.0", "version": "1.0.2",
"private": false, "private": false,
"packageManager": "pnpm@8.7.4", "packageManager": "pnpm@8.7.4",
"description": "Nuxt 3 module for MongoDB with Mongoose", "description": "Nuxt 3 module for MongoDB with Mongoose",
@ -10,7 +10,7 @@
"homepage": "https://nuxt-mongoose.nuxt.space", "homepage": "https://nuxt-mongoose.nuxt.space",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/arashsheyda/nuxt-mongoose" "url": "git+https://github.com/arashsheyda/nuxt-mongoose"
}, },
"bugs": { "bugs": {
"url": "https://github.com/arashsheyda/nuxt-mongoose/issues" "url": "https://github.com/arashsheyda/nuxt-mongoose/issues"
@ -39,19 +39,19 @@
"dist" "dist"
], ],
"scripts": { "scripts": {
"prepare": "nuxt-module-build --stub && nuxi prepare client",
"build": "nuxt-module-build && npm run build:client", "build": "nuxt-module-build && npm run build:client",
"build:client": "nuxi generate client", "build:client": "nuxi generate client",
"dev": "nuxi dev playground", "dev": "nuxi dev playground",
"dev:prepare": "nuxt-module-build && nuxi prepare client",
"dev:client": "nuxi dev client --port 3300", "dev:client": "nuxi dev client --port 3300",
"dev:prod": "npm run build && npm run dev", "dev:prod": "npm run build && npm run dev",
"release": "npm run lint && npm run build && changelogen --release && npm publish", "release": "npm run lint && npm run build && changelogen --release && npm publish",
"lint": "eslint . --fix" "lint": "eslint . --fix"
}, },
"dependencies": { "dependencies": {
"@nuxt/devtools-kit": "^0.8.2", "@nuxt/devtools-kit": "^0.8.4",
"@nuxt/devtools-ui-kit": "^0.8.2", "@nuxt/devtools-ui-kit": "^0.8.4",
"@nuxt/kit": "^3.7.1", "@nuxt/kit": "^3.7.3",
"@vueuse/core": "^10.4.1", "@vueuse/core": "^10.4.1",
"defu": "^6.1.2", "defu": "^6.1.2",
"fs-extra": "^11.1.1", "fs-extra": "^11.1.1",
@ -62,13 +62,13 @@
"sirv": "^2.0.3" "sirv": "^2.0.3"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^0.41.0", "@antfu/eslint-config": "^0.43.0",
"@nuxt/module-builder": "^0.5.1", "@nuxt/module-builder": "^0.5.1",
"@types/fs-extra": "^11.0.2", "@types/fs-extra": "^11.0.2",
"@types/pluralize": "^0.0.30", "@types/pluralize": "^0.0.30",
"changelogen": "^0.5.5", "changelogen": "^0.5.5",
"eslint": "8.48.0", "eslint": "8.49.0",
"nuxt": "^3.7.1", "nuxt": "^3.7.3",
"sass": "^1.67.0", "sass": "^1.67.0",
"sass-loader": "^13.3.2", "sass-loader": "^13.3.2",
"splitpanes": "^3.1.5" "splitpanes": "^3.1.5"

2922
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ import {
import type { ConnectOptions } from 'mongoose' import type { ConnectOptions } from 'mongoose'
import defu from 'defu' import defu from 'defu'
import { join } from 'pathe' import { join } from 'pathe'
import mongoose from 'mongoose'
import { $fetch } from 'ofetch' import { $fetch } from 'ofetch'
import { version } from '../package.json' import { version } from '../package.json'
import { setupDevToolsUI } from './devtools' import { setupDevToolsUI } from './devtools'
@ -18,27 +19,27 @@ export interface ModuleOptions {
* *
* @default process.env.MONGODB_URI * @default process.env.MONGODB_URI
* *
*/ */
uri: string | undefined uri: string | undefined
/** /**
* Nuxt DevTools * Nuxt DevTools
* *
* @default true * @default true
* *
*/ */
devtools: boolean devtools: boolean
/** /**
* Mongoose Connections * Mongoose Connections
* *
* @default {} * @default {}
*/ */
options?: ConnectOptions options?: ConnectOptions
/** /**
* Models Directory for auto-import * Models Directory for auto-import
* *
* @default 'models' * @default 'models'
* *
*/ */
modelsDir?: string modelsDir?: string
} }
@ -54,6 +55,11 @@ export default defineNuxtModule<ModuleOptions>({
options: {}, options: {},
modelsDir: 'models', modelsDir: 'models',
}, },
hooks: {
close: () => {
mongoose.disconnect()
},
},
async setup(options, nuxt) { async setup(options, nuxt) {
if (nuxt.options.dev) { if (nuxt.options.dev) {
$fetch('https://registry.npmjs.org/nuxt-mongoose/latest').then((release) => { $fetch('https://registry.npmjs.org/nuxt-mongoose/latest').then((release) => {