Merge branch 'main' of https://github.com/arashsheyda/nuxt-mongoose
This commit is contained in:
@ -12,13 +12,17 @@ This function creates a new Mongoose model with schema. Example usage:
|
||||
export const User = defineMongooseModel({
|
||||
name: 'User',
|
||||
schema: {
|
||||
name: {
|
||||
type: String,
|
||||
email: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
},
|
||||
options: {
|
||||
|
||||
},
|
||||
hooks(schema) {
|
||||
|
||||
},
|
||||
})
|
||||
```
|
||||
@ -27,18 +31,31 @@ This function creates a new Mongoose model with schema. Example usage:
|
||||
import { defineMongooseModel } from '#nuxt/mongoose'
|
||||
|
||||
export const User = defineMongooseModel('User', {
|
||||
name: {
|
||||
type: String,
|
||||
email: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
}, {
|
||||
|
||||
}, (schema) => {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
::
|
||||
|
||||
|
||||
| **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`
|
||||
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).
|
||||
|
||||
Reference in New Issue
Block a user