Skip to content

Commit

Permalink
chore: update readme with documentation redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
arashsheyda committed Feb 26, 2024
1 parent 3040751 commit 89d50bd
Showing 1 changed file with 1 addition and 56 deletions.
57 changes: 1 addition & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,62 +29,7 @@ export default defineNuxtConfig({

### Configuration

You can configure the module by adding a `mongoose` section to your `nuxt.config` file.

```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,
},
},
})
```
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/).

## License

Expand Down

0 comments on commit 89d50bd

Please sign in to comment.