1.0.0 • Published 4 years ago

cp-mongodb v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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)