🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

beanify-mongoose

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beanify-mongoose

beanify操作mongodb插件

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
16
166.67%
Maintainers
1
Weekly downloads
 
Created
Source

beanify-mongoose

beanify操作mongodb插件

安装

npm i beanify-mongoose --save

with yarn

yarn add beanify-mongoose

例子

const Beanify = require('beanify')
const mongoose = require('beanify-mongoose')
const beanify = Beanify({})

beanify
  .register(mongoose, {
    uri: 'mongodb://127.0.0.1:27017/test?readPreference=primary&appname=MongoDB%20Compass&ssl=false',
    models: [
      {
        name: 'test',
        alias: 'Test',
        schema: {
          test: {
            type: 'String'
          }
        }
      }
    ]
  })
  .ready(e => {
    e && beanify.$log.error(e.message)
    beanify.print()
    await beanify.mongoose.Test.deleteMany()
    await beanify.mongoose.Test.create({
      test: 'this is test'
    })
    const doc = await beanify.mongoose.Test.findOne()
    console.log(doc.test) // this is test
  })

参数

字段类型描述
uristringmongoDB服务地址
models?[object]数据模型列表
useNameAndAlias?boolean是否启用模型别名
settings?mongoosemongoose库的配置参数

Keywords

beanify-mongodb

FAQs

Package last updated on 30 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts