添加说明
This commit is contained in:
parent
31ab82fd75
commit
cf0a16ef15
@ -62,6 +62,9 @@ let remove = (set,where,url = dburl) =>{
|
|||||||
}
|
}
|
||||||
let removes = (set,where,url = dburl) =>{
|
let removes = (set,where,url = dburl) =>{
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
if(where == "" ||Object.keys(where).length == 0){
|
||||||
|
reject({code:1})
|
||||||
|
}
|
||||||
MongoClient.connect(url.url, { useNewUrlParser: true }, function(err, db) {
|
MongoClient.connect(url.url, { useNewUrlParser: true }, function(err, db) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
var dbo = db.db(url.dbname);
|
var dbo = db.db(url.dbname);
|
||||||
|
@ -2,11 +2,52 @@
|
|||||||
- 引入
|
- 引入
|
||||||
- dbs = require("dir/mongodb.js")
|
- dbs = require("dir/mongodb.js")
|
||||||
- 使用<br>
|
- 使用<br>
|
||||||
add
|
add 插入一条数据
|
||||||
|
```
|
||||||
```
|
参数(操作的集合名,数据集 {}[,{数据库地址,数据库名}])
|
||||||
参数(操作的集合名,数据集 {}[,{mongodburl,dbname}])
|
返回值类型 promise
|
||||||
返回值类型 promise
|
成功返回 {code:0},
|
||||||
成功返回 {code:0},
|
失败返回 {code:1}
|
||||||
失败返回 {code:1}
|
```
|
||||||
```
|
adds 插入多条数据
|
||||||
|
```
|
||||||
|
参数(操作的集合名,数据集 [{}][,{数据库地址,数据库名}])
|
||||||
|
返回值类型 promise
|
||||||
|
成功返回 {code:0},
|
||||||
|
失败返回 {code:1}
|
||||||
|
```
|
||||||
|
remove 删除一个数据
|
||||||
|
```
|
||||||
|
参数(操作的集合名,条件[,{数据库地址,数据库名}])
|
||||||
|
返回值类型 promise
|
||||||
|
成功返回 {code:0},
|
||||||
|
失败返回 {code:1}
|
||||||
|
```
|
||||||
|
remove 删除多条数据
|
||||||
|
```
|
||||||
|
参数(操作的集合名,条件 为空全部删除 但是禁止为空[,{数据库地址,数据库名}])
|
||||||
|
返回值类型 promise
|
||||||
|
成功返回 {code:0,num:删除的条数},
|
||||||
|
失败返回 {code:1}
|
||||||
|
```
|
||||||
|
find 查询数据
|
||||||
|
```
|
||||||
|
参数(操作的集合名,条件 为空为全部数据[,{数据库地址,数据库名}])
|
||||||
|
返回值类型 promise
|
||||||
|
成功返回 {code:0,data:[数据集]},
|
||||||
|
失败返回 {code:1}
|
||||||
|
```
|
||||||
|
update 更新单条数据
|
||||||
|
```
|
||||||
|
参数(操作的集合名,条件,要改为的{}[,{数据库地址,数据库名}])
|
||||||
|
返回值类型 promise
|
||||||
|
成功返回 {code:0},
|
||||||
|
失败返回 {code:1}
|
||||||
|
```
|
||||||
|
updates 更新多条数据
|
||||||
|
```
|
||||||
|
参数(操作的集合名,条件,要改为的{}[,{数据库地址,数据库名}])
|
||||||
|
返回值类型 promise
|
||||||
|
成功返回 {code:0,num:修改成功的数量},
|
||||||
|
失败返回 {code:1}
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user