cp-mongodb

1.0.0 • Public • Published

cp-mongodb

封装项目中常用到的文件上传发布,下载和存储

安装模块

cnpm i mongodb -S
cnpm i cp-mongodb -S

创建数据库连接

const mongodb = requier('cp-mongodb')
const mgConfig = {
  db: '' // 数据库
  user: '', // 数据库用户名
  pass: '' // 数据库密码
  host: '' // mongodb服务器
}
mongodb.createConnect(mgConfig)

新增数据

mongodb.add(res, table, params)

查询数据

// isList为true时为查询列表,false时为查询详情
mongodb.query(res, table, params, isList)

删除数据

// 通过自带的_id删除,可以传入字符串和数组
mongodb.del(res, table, params)

更新数据

// 通过数据的_id作为唯一标识更新
mongodb.update(res, table, params)

Readme

Keywords

Package Sidebar

Install

npm i cp-mongodb

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

9.79 kB

Total Files

10

Last publish

Collaborators

  • zhangliapp