feat: documentation
This commit is contained in:
36
docs/content/0.index.md
Normal file
36
docs/content/0.index.md
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
title: Home
|
||||
navigation: false
|
||||
layout: page
|
||||
main:
|
||||
fluid: false
|
||||
---
|
||||
|
||||
:ellipsis{right=0px width=75% blur=150px}
|
||||
|
||||
::block-hero
|
||||
---
|
||||
cta:
|
||||
- Get started
|
||||
- /getting-started/setup
|
||||
secondary:
|
||||
- Open on GitHub →
|
||||
- https://github.com/arashsheyda/nuxt-mongoose
|
||||
---
|
||||
|
||||
#title
|
||||
Nuxt Mongoose
|
||||
|
||||
#description
|
||||
A Nuxt module for simplifying the use of [Mongoose](https://mongoosejs.com/) in your project.
|
||||
|
||||
#support
|
||||
::terminal
|
||||
---
|
||||
content:
|
||||
- npm i nuxt-mongoose -D
|
||||
---
|
||||
::
|
||||
::
|
||||
|
||||
<!-- TODO: features -->
|
||||
51
docs/content/1.getting-started/1.setup.md
Normal file
51
docs/content/1.getting-started/1.setup.md
Normal file
@ -0,0 +1,51 @@
|
||||
# Setup
|
||||
|
||||
A Nuxt module for simplifying the use of Mongoose in your project.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install `nuxt-mongoose` to your dependencies.
|
||||
|
||||
::code-group
|
||||
|
||||
```bash [pnpm]
|
||||
pnpm add nuxt-mongoose -D
|
||||
```
|
||||
|
||||
```bash [npm]
|
||||
npm install nuxt-mongoose -D
|
||||
```
|
||||
|
||||
```bash [yarn]
|
||||
yarn add nuxt-mongoose -D
|
||||
```
|
||||
|
||||
::
|
||||
|
||||
2. Add `nuxt-mongoose` to the `modules` section of your `nuxt.config` file.
|
||||
|
||||
```ts [nuxt.config]
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
'nuxt-mongoose',
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
::alert{ type=success }
|
||||
That's it! You can now use Mongoose in your Nuxt app ✨
|
||||
::
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
You can configure the module by adding a `mongoose` section to your `nuxt.config` file.
|
||||
read more about [Mongoose options](/getting-started/configuration).
|
||||
|
||||
```ts [nuxt.config]
|
||||
export default defineNuxtConfig({
|
||||
mongoose: {
|
||||
// Options
|
||||
},
|
||||
})
|
||||
```
|
||||
21
docs/content/1.getting-started/3.configuration.md
Normal file
21
docs/content/1.getting-started/3.configuration.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Configuration
|
||||
|
||||
Configure Nuxt Mongoose with the `mongoose` property.
|
||||
|
||||
```ts [nuxt.config]
|
||||
export default defineNuxtConfig({
|
||||
mongoose: {
|
||||
uri: 'process.env.MONGODB_URI',
|
||||
options: {},
|
||||
modelsDir: 'models',
|
||||
devtools: true,
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
| **Key** | **Type** | **Default** | **Description** |
|
||||
| ---------------------------- | ---------- | ----------------------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| `uri` | `string` | process.env.MONGODB_URI | Connection Uri String |
|
||||
| `options` | `ConnectOptions` | { } | Connection Options |
|
||||
| `modelsDir` | `string` | models | The models(schema) directory located in `server` for auto-import |
|
||||
| `devtools` | `boolean` | true | Enable Mongoose module in [`Nuxt Devtools`](https://github.com/nuxt/devtools) |
|
||||
2
docs/content/1.getting-started/_dir.yml
Normal file
2
docs/content/1.getting-started/_dir.yml
Normal file
@ -0,0 +1,2 @@
|
||||
icon: tabler:brand-mongodb
|
||||
navigation.redirect: /getting-started/setup
|
||||
52
docs/content/2.api/1.utils.md
Normal file
52
docs/content/2.api/1.utils.md
Normal file
@ -0,0 +1,52 @@
|
||||
# Utils
|
||||
|
||||
Discover all available utils.
|
||||
|
||||
## `defineMongooseModel`
|
||||
|
||||
This function creates a new Mongoose model with schema. Example usage:
|
||||
|
||||
::code-group
|
||||
|
||||
```ts [named parameters]
|
||||
export const User = defineMongooseModel({
|
||||
name: 'User',
|
||||
schema: {
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
options: {
|
||||
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
```ts [positional parameters]
|
||||
import { defineMongooseModel } from '#nuxt/mongoose'
|
||||
|
||||
export const User = defineMongooseModel('User', {
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
}, {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
::
|
||||
|
||||
|
||||
## `defineMongooseConnection`
|
||||
This function creates a new Mongoose connection.
|
||||
- `nuxt-mongoose` provides a default connection for you, it auto-register a plugin in nitro, so you don't need to use this function unless you want to create a new connection. more info [here](https://github.com/arashsheyda/nuxt-mongoose/blob/main/src/runtime/server/plugins/mongoose.db.ts).
|
||||
|
||||
Example usage:
|
||||
|
||||
```ts
|
||||
import { defineMongooseConnection } from '#nuxt/mongoose'
|
||||
|
||||
export const connection = defineMongooseConnection('mongodb://127.0.0.1/nuxt-mongoose')
|
||||
```
|
||||
3
docs/content/2.api/2.devtools.md
Normal file
3
docs/content/2.api/2.devtools.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Devtools (beta)
|
||||
|
||||
`nuxt-mongoose` comes with a [Nuxt Devtools](https://github.com/nuxt/devtools) module that allows you to manage your collections and generate api-endpoints & schemas...
|
||||
2
docs/content/2.api/_dir.yml
Normal file
2
docs/content/2.api/_dir.yml
Normal file
@ -0,0 +1,2 @@
|
||||
title: API
|
||||
icon: tabler:book
|
||||
Reference in New Issue
Block a user