1.0.1-0snYiGDvvudLa7fDo3NlYLe2IeidVmyoCYI1LXN6Wsml • Published 9 months ago
nuxt-mongoose-edge v1.0.1-0snYiGDvvudLa7fDo3NlYLe2IeidVmyoCYI1LXN6Wsml
A Nuxt module for simplifying the use of Mongoose in your project.
Installation
pnpm add nuxt-mongoose
Usage
Setup
Add nuxt-mongoose
to the modules
section of your nuxt.config.ts
file.
export default defineNuxtConfig({
modules: [
'nuxt-mongoose',
],
})
Configuration
You can configure the module by adding a mongoose
section to your nuxt.config
file.
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. *
API
defineMongooseConnection
This function creates a new Mongoose connection. Example usage:
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:
import { defineMongooseModel } from '#nuxt/mongoose'
export const User = defineMongooseModel('User', {
name: {
type: String,
required: true,
},
})
or you could use it like:
export const User = defineMongooseModel({
name: 'User',
schema: {
name: {
type: String,
required: true,
},
},
})
License
1.0.1
9 months ago
0.0.9-3VFF8t5gzXdfjjOZiwAfTq7OyNEZaEV0qM4Iiu6d
9 months ago
0.0.9
9 months ago
0.0.8-ynqwj37gi4po080v52c01
11 months ago
0.0.8-rfhi70em8v30lcq87qu7
11 months ago
0.0.5-f417bced1e97fbef5e4b13cf3f441770
1 year ago
0.0.5-eb3f912d4a14e436873d8f16db55a382
1 year ago
0.0.5-ed54cba538a99d1871a8e29c266856b8
1 year ago
0.0.5-a4b2395ac4e337616e38c02db0ea6aa8
1 year ago
0.0.5-aaa43678a75895d4fb2eaac7ac8db13b
1 year ago
0.0.5-a6d5dd27231d4117cf8d3882c9896bb3
1 year ago
0.0.5-f27f4439097be182846155a1a49a3e31
1 year ago
0.0.5-5f340b49dee9ce07d448ee1ea2644c45
1 year ago