chore: update readme with documentation redirection

This commit is contained in:
Arash
2024-02-26 10:11:45 -07:00
committed by GitHub
parent 30407511a4
commit 89d50bd977

View File

@ -29,62 +29,7 @@ export default defineNuxtConfig({
### Configuration ### Configuration
You can configure the module by adding a `mongoose` section to your `nuxt.config` file. For detailed [configuration](https://nuxt-mongoose.nuxt.space/docs/getting-started/configuration) and usage instructions, please refer to our [documentation](https://nuxt-mongoose.nuxt.space/).
```ts
export default defineNuxtConfig({
mongoose: {
uri: 'process.env.MONGODB_URI',
options: {},
modelsDir: 'models',
},
})
```
by default, `nuxt-mongoose` will auto-import your schemas from the `models` directory from `server` directory. You can change this behavior by setting the `modelsDir` option.
* for more information about the options, please refer to the [Mongoose documentation](https://mongoosejs.com/docs/connections.html#options). *
## API
### defineMongooseConnection
This function creates a new Mongoose connection. Example usage:
```ts
import { defineMongooseConnection } from '#nuxt/mongoose'
export const connection = defineMongooseConnection('mongodb://127.0.0.1/nuxt-mongoose')
```
### defineMongooseModel
This function creates a new Mongoose model with schema. Example usage:
```ts
import { defineMongooseModel } from '#nuxt/mongoose'
export const User = defineMongooseModel('User', {
name: {
type: String,
required: true,
},
})
```
**or you could use it like:**
```ts
export const User = defineMongooseModel({
name: 'User',
schema: {
name: {
type: String,
required: true,
},
},
})
```
## License ## License