From 110d8ea1eedf93c794958de2be477a91352dcd47 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:37:56 +0800 Subject: [PATCH 01/15] mongodb --- description/mongodb.js.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 description/mongodb.js.md diff --git a/description/mongodb.js.md b/description/mongodb.js.md new file mode 100644 index 0000000..68f82f9 --- /dev/null +++ b/description/mongodb.js.md @@ -0,0 +1,11 @@ +#mongodb.js说明 +- 引入 + - dbs = require("dir/mongodb.js") +- 使用 + - add + ``` + 参数('操作的集合名',数据集 {}[,{mongodburl,dbname}]) + 返回值类型 promise + 成功返回 {code:0}, + 失败返回 {code:1} + ``` From cbf13bdbcf550f6a96f121b7a8fce8d3ea9ad189 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:38:45 +0800 Subject: [PATCH 02/15] a --- description/mongodb.js.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 68f82f9..2c0acb3 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -2,7 +2,7 @@ - 引入 - dbs = require("dir/mongodb.js") - 使用 - - add + add ``` 参数('操作的集合名',数据集 {}[,{mongodburl,dbname}]) 返回值类型 promise From dfc24079cc1d6f9f106c38ee7e8e753a5fd209bc Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:39:16 +0800 Subject: [PATCH 03/15] a --- description/mongodb.js.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 2c0acb3..b34a351 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -1,7 +1,7 @@ #mongodb.js说明 - 引入 - dbs = require("dir/mongodb.js") -- 使用 +- 使用 \n add ``` 参数('操作的集合名',数据集 {}[,{mongodburl,dbname}]) From e603db8843f12b8acb9d89ba24bca2452d3e8527 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:40:04 +0800 Subject: [PATCH 04/15] a --- description/mongodb.js.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index b34a351..351d5ec 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -1,7 +1,7 @@ #mongodb.js说明 - 引入 - dbs = require("dir/mongodb.js") -- 使用 \n +- 使用
add ``` 参数('操作的集合名',数据集 {}[,{mongodburl,dbname}]) From c07e8e8c90f10c5579a473a235ca2ccae78a2f5d Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:40:28 +0800 Subject: [PATCH 05/15] a --- description/mongodb.js.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 351d5ec..2871253 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -3,6 +3,8 @@ - dbs = require("dir/mongodb.js") - 使用
add + + ``` 参数('操作的集合名',数据集 {}[,{mongodburl,dbname}]) 返回值类型 promise From dab90ad48d1923fff07801c0c151e213efe42e9a Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:41:09 +0800 Subject: [PATCH 06/15] a --- description/mongodb.js.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 2871253..05681f4 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -2,12 +2,10 @@ - 引入 - dbs = require("dir/mongodb.js") - 使用
- add - - - ``` - 参数('操作的集合名',数据集 {}[,{mongodburl,dbname}]) - 返回值类型 promise - 成功返回 {code:0}, - 失败返回 {code:1} - ``` + add
+ ``` + 参数('操作的集合名',数据集 {}[,{mongodburl,dbname}]) + 返回值类型 promise + 成功返回 {code:0}, + 失败返回 {code:1} + ``` \ No newline at end of file From 82a86f8b3129ad0879532ed0a3832d9b022f7596 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:41:55 +0800 Subject: [PATCH 07/15] a --- description/mongodb.js.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 05681f4..33191ed 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -2,10 +2,10 @@ - 引入 - dbs = require("dir/mongodb.js") - 使用
- add
- ``` - 参数('操作的集合名',数据集 {}[,{mongodburl,dbname}]) - 返回值类型 promise - 成功返回 {code:0}, - 失败返回 {code:1} - ``` \ No newline at end of file + add
+ ``` + 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}]) + 返回值类型 promise + 成功返回 {code:0}, + 失败返回 {code:1} + ``` \ No newline at end of file From 874a0e5f61056c45eae8fa3da5f3b416d59d4349 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:42:31 +0800 Subject: [PATCH 08/15] a --- description/mongodb.js.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 33191ed..eaf3660 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -4,8 +4,8 @@ - 使用
add
``` - 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}]) - 返回值类型 promise - 成功返回 {code:0}, - 失败返回 {code:1} + 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}])
+ 返回值类型 promise
+ 成功返回 {code:0},
+ 失败返回 {code:1}
``` \ No newline at end of file From afa77a4228b911d7e43626cf37bbf11c0e7e6b2a Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:43:26 +0800 Subject: [PATCH 09/15] a --- description/mongodb.js.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index eaf3660..aed4c55 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -2,7 +2,7 @@ - 引入 - dbs = require("dir/mongodb.js") - 使用
- add
+ add ``` 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}])
返回值类型 promise
From aa4b31a080628f1404319b22640bdf1d8c907d97 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:43:58 +0800 Subject: [PATCH 10/15] a --- description/mongodb.js.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index aed4c55..7f742b2 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -4,8 +4,8 @@ - 使用
add ``` - 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}])
- 返回值类型 promise
- 成功返回 {code:0},
- 失败返回 {code:1}
+ 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}]) + 返回值类型 promise + 成功返回 {code:0}, + 失败返回 {code:1} ``` \ No newline at end of file From 317d3e9eaf89b1c57066dd7dddc56cf59276842a Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:44:24 +0800 Subject: [PATCH 11/15] a --- description/mongodb.js.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 7f742b2..97dedaf 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -1,7 +1,7 @@ #mongodb.js说明 - 引入 - dbs = require("dir/mongodb.js") -- 使用
+- 使用 add ``` 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}]) From c948e6387dd421f41d44dd3df7b7f5c61d92a3e2 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:44:48 +0800 Subject: [PATCH 12/15] a --- description/mongodb.js.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 97dedaf..5096a47 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -1,11 +1,11 @@ #mongodb.js说明 - 引入 - dbs = require("dir/mongodb.js") -- 使用 - add - ``` - 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}]) - 返回值类型 promise - 成功返回 {code:0}, - 失败返回 {code:1} - ``` \ No newline at end of file +- 使用
+add +``` +参数(操作的集合名,数据集 {}[,{mongodburl,dbname}]) +返回值类型 promise +成功返回 {code:0}, +失败返回 {code:1} +``` \ No newline at end of file From 31ab82fd753bdd6218517414b7f31e30af89e31c Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:45:05 +0800 Subject: [PATCH 13/15] a --- description/mongodb.js.md | 1 + 1 file changed, 1 insertion(+) diff --git a/description/mongodb.js.md b/description/mongodb.js.md index 5096a47..aa97fe9 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -3,6 +3,7 @@ - dbs = require("dir/mongodb.js") - 使用
add + ``` 参数(操作的集合名,数据集 {}[,{mongodburl,dbname}]) 返回值类型 promise From cf0a16ef15008d8a905792eba7bd605df3e0048e Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:54:52 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/mongodb.js | 3 +++ description/mongodb.js.md | 57 +++++++++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/bin/mongodb.js b/bin/mongodb.js index fcde83a..cfa09f4 100644 --- a/bin/mongodb.js +++ b/bin/mongodb.js @@ -62,6 +62,9 @@ let remove = (set,where,url = dburl) =>{ } let removes = (set,where,url = dburl) =>{ return new Promise((resolve, reject) => { + if(where == "" ||Object.keys(where).length == 0){ + reject({code:1}) + } MongoClient.connect(url.url, { useNewUrlParser: true }, function(err, db) { if (err) throw err; var dbo = db.db(url.dbname); diff --git a/description/mongodb.js.md b/description/mongodb.js.md index aa97fe9..916fb59 100644 --- a/description/mongodb.js.md +++ b/description/mongodb.js.md @@ -2,11 +2,52 @@ - 引入 - dbs = require("dir/mongodb.js") - 使用
-add - -``` -参数(操作的集合名,数据集 {}[,{mongodburl,dbname}]) -返回值类型 promise -成功返回 {code:0}, -失败返回 {code:1} -``` \ No newline at end of file +add 插入一条数据 + ``` + 参数(操作的集合名,数据集 {}[,{数据库地址,数据库名}]) + 返回值类型 promise + 成功返回 {code:0}, + 失败返回 {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} + ``` From 9df897fc849e0faf57ebb27160c937b8bbad1e06 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Tue, 12 Nov 2019 23:56:24 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1678afe..74663bb 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,4 @@ label.js 标签路由 login.js 登录路由 ~~~ +[mongodb.js](http://git.luyuan.tk/pplokijuhyg/blog-server/src/branch/master/description/mongodb.js.md) \ No newline at end of file