Skip to content

Commit

Permalink
docs(utils): add hooks and improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
arashsheyda committed Jul 9, 2023
1 parent 40b8ca9 commit 647d26d
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions docs/content/2.api/1.utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ 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) {

},
})
Expand All @@ -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).
Expand Down

0 comments on commit 647d26d

Please sign in to comment.