Merge branch 'main' of https://github.com/arashsheyda/nuxt-mongoose
This commit is contained in:
@ -12,12 +12,16 @@ This function creates a new Mongoose model with schema. Example usage:
|
|||||||
export const User = defineMongooseModel({
|
export const User = defineMongooseModel({
|
||||||
name: 'User',
|
name: 'User',
|
||||||
schema: {
|
schema: {
|
||||||
name: {
|
email: {
|
||||||
type: String,
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
|
unique: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
|
||||||
|
},
|
||||||
|
hooks(schema) {
|
||||||
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -27,11 +31,14 @@ This function creates a new Mongoose model with schema. Example usage:
|
|||||||
import { defineMongooseModel } from '#nuxt/mongoose'
|
import { defineMongooseModel } from '#nuxt/mongoose'
|
||||||
|
|
||||||
export const User = defineMongooseModel('User', {
|
export const User = defineMongooseModel('User', {
|
||||||
name: {
|
email: {
|
||||||
type: String,
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
|
unique: true,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
|
||||||
|
}, (schema) => {
|
||||||
|
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@ -39,6 +46,16 @@ This function creates a new Mongoose model with schema. Example usage:
|
|||||||
::
|
::
|
||||||
|
|
||||||
|
|
||||||
|
| **Key** | **Type** | **Require** | **Description** |
|
||||||
|
| ---------------------------- | ----------- | ----------- | ----- |
|
||||||
|
| `name` | `string` | true | Name of Model |
|
||||||
|
| `schema` | `SchemaDefinition` | true | Schema Definition of Model |
|
||||||
|
| `options` | `SchemaDefinition` | false | Schema Options for Model |
|
||||||
|
| `hooks` | `(schema: Schema<T>) => void` | false | Schema Hooks Function to customize Model |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## `defineMongooseConnection`
|
## `defineMongooseConnection`
|
||||||
This function creates a new Mongoose connection.
|
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).
|
- `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).
|
||||||
|
|||||||
Reference in New Issue
Block a user