Skip to content

Commit d32f43e

Browse files
committed
add mongose && nodemailer
1 parent 2ceeec6 commit d32f43e

21 files changed

+2999
-13
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/node_modules
2+
.uini
3+
Error*
4+
*.php
5+
*.conf
6+
*.DS_Store
7+
*.project
8+
src/*.log

all.json

+1
Large diffs are not rendered by default.

connection.js

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
var MongoClient = require('mongodb').MongoClient;
2+
var DB_CONN_STR = 'mongodb://localhost:27017/anglo';
3+
4+
var insertData = function(db, callback) {
5+
//插入数据
6+
var data = [{"name":'wilson001',"age":21},{"name":'wilson002',"age":22}];
7+
collection.insert(data, function(err, result) {
8+
if(err)
9+
{
10+
console.log('Error:'+ err);
11+
return;
12+
}
13+
console.log("插入成功");
14+
callback(result);
15+
});
16+
}
17+
var selectData = function(db, callback) {
18+
var collection = db.collection('anglo_coll');//连接到表
19+
//查询数据
20+
var whereStr = {};
21+
collection.find(whereStr).toArray(function(err, result) {
22+
if(err)
23+
{
24+
console.log('Error:'+ err);
25+
return;
26+
}
27+
console.log("查询成功");
28+
callback(result);
29+
});
30+
}
31+
32+
var updateData = function(db, callback) {
33+
var collection = db.collection('anglo_coll');//连接到表
34+
//更新数据
35+
var whereStr = {"name":'wilson001'};
36+
var updateStr = {$set: { "age" : 100 }};
37+
collection.update(whereStr,updateStr, function(err, result) {
38+
if(err)
39+
{
40+
console.log('Error:'+ err);
41+
return;
42+
}
43+
console.log("更新成功");
44+
callback(result);
45+
});
46+
}
47+
48+
var delData = function(db, callback) {
49+
//连接到表
50+
var collection = db.collection('anglo_coll');
51+
//删除数据
52+
var whereStr = {"z":1};
53+
collection.remove(whereStr, function(err, result) {
54+
if(err)
55+
{
56+
console.log('Error:'+ err);
57+
return;
58+
}
59+
console.log("删除成功");
60+
callback(result);
61+
});
62+
}
63+
64+
65+
var invokeProcData = function(db, callback) {
66+
//存储过程调用
67+
db.eval('get_tb2count()', function(err, result) {
68+
if(err)
69+
{
70+
console.log('Error:'+ err);
71+
return;
72+
}
73+
console.log("存储过程调用");
74+
callback(result);
75+
});
76+
}
77+
var get_tb2_count = function(db, callback){
78+
//连接到表
79+
var collection = db.collection('anglo_coll');
80+
var counter = collection.find({}).count();
81+
console.log(counter)
82+
}
83+
MongoClient.connect(DB_CONN_STR, function(err, db) {
84+
// updateData(db, function(result) {
85+
// db.close();
86+
// });
87+
// selectData(db, function(result) {
88+
// console.log(result);
89+
// db.close();
90+
// });
91+
delData(db, function(result) {
92+
db.close();
93+
});
94+
selectData(db, function(result) {
95+
console.log(result);
96+
db.close();
97+
});
98+
get_tb2_count(db, function(result) {
99+
db.close();
100+
});
101+
});
102+

contacts.xlsx

90.4 KB
Binary file not shown.

cpFile.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* @Author: black
3+
* @Date: 2017-05-26 13:56:37
4+
* @Last Modified by: black
5+
* @Last Modified time: 2017-05-26 13:57:16
6+
*/
7+
8+
9+
'use strict';
10+
var fs = require( 'fs' );
11+
12+
/*
13+
* 复制目录、子目录,及其中的文件
14+
* @param src {String} 要复制的目录
15+
* @param dist {String} 复制到目标目录
16+
*/
17+
function copyDir(src, dist, callback) {
18+
fs.access(dist, function(err){
19+
if(err){
20+
// 目录不存在时创建目录
21+
fs.mkdirSync(dist);
22+
}
23+
_copy(null, src, dist);
24+
});
25+
26+
function _copy(err, src, dist) {
27+
if(err){
28+
callback(err);
29+
} else {
30+
fs.readdir(src, function(err, paths) {
31+
if(err){
32+
callback(err)
33+
} else {
34+
paths.forEach(function(path) {
35+
var _src = src + '/' +path;
36+
var _dist = dist + '/' +path;
37+
fs.stat(_src, function(err, stat) {
38+
if(err){
39+
callback(err);
40+
} else {
41+
// 判断是文件还是目录
42+
if(stat.isFile()) {
43+
fs.writeFileSync(_dist, fs.readFileSync(_src));
44+
} else if(stat.isDirectory()) {
45+
// 当是目录是,递归复制
46+
copyDir(_src, _dist, callback)
47+
}
48+
}
49+
})
50+
})
51+
}
52+
})
53+
}
54+
}
55+
}
56+
57+
copyDir('./test', './new', function(err){
58+
if(err){
59+
console.log(err);
60+
}
61+
})

example-connection.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var mongoDbConnection = require('./connection.js');
2+
3+
exports.index = function(req, res, next) {
4+
mongoDbConnection(function(databaseConnection) {
5+
databaseConnection.collection('anglo_coll', function(error, collection) {
6+
collection.find().toArray(function(error, results) {
7+
console.log(results)
8+
});
9+
});
10+
});
11+
};

index.js fs.js

File renamed without changes.

hello.html

+65
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,73 @@
44
<meta charset="utf-8">
55
<title>hello</title>
66
<link rel="stylesheet" type="text/css" href="css/hello.css">
7+
<style>
8+
body {
9+
padding: 1em;
10+
color: #777;
11+
text-align: center;
12+
font-family: "Gill sans", sans-serif;
13+
width: 80%;
14+
margin: 0 auto;
15+
}
16+
h1 {
17+
margin: 1em 0;
18+
border-bottom: 1px dashed;
19+
padding-bottom: 1em;
20+
font-weight: lighter;
21+
}
22+
p {
23+
font-style: italic;
24+
}
25+
.loader {
26+
margin: 0 0 2em;
27+
height: 100px;
28+
width: 20%;
29+
text-align: center;
30+
padding: 1em;
31+
margin: 0 auto 1em;
32+
display: inline-block;
33+
vertical-align: top;
34+
}
35+
/*
36+
Set the color of the icon
37+
*/
38+
svg path,
39+
svg rect {
40+
fill: #FF6700;
41+
}
42+
</style>
743
</head>
844
<body>
945
<div style="color: red">hahhahahha</div>
46+
<div class="loader loader--style6" title="5">
47+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="30px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">
48+
<rect x="0" y="13" width="4" height="5" fill="#333">
49+
<animate attributeName="height" attributeType="XML"
50+
values="5;21;5"
51+
begin="0s" dur="0.6s" repeatCount="indefinite" />
52+
<animate attributeName="y" attributeType="XML"
53+
values="13; 5; 13"
54+
begin="0s" dur="0.6s" repeatCount="indefinite" />
55+
</rect>
56+
<rect x="10" y="13" width="4" height="5" fill="#333">
57+
<animate attributeName="height" attributeType="XML"
58+
values="5;21;5"
59+
begin="0.15s" dur="0.6s" repeatCount="indefinite" />
60+
<animate attributeName="y" attributeType="XML"
61+
values="13; 5; 13"
62+
begin="0.15s" dur="0.6s" repeatCount="indefinite" />
63+
</rect>
64+
<rect x="20" y="13" width="4" height="5" fill="#333">
65+
<animate attributeName="height" attributeType="XML"
66+
values="5;21;5"
67+
begin="0.3s" dur="0.6s" repeatCount="indefinite" />
68+
<animate attributeName="y" attributeType="XML"
69+
values="13; 5; 13"
70+
begin="0.3s" dur="0.6s" repeatCount="indefinite" />
71+
</rect>
72+
</svg>
73+
</div>
74+
1075
</body>
1176
</html>

0 commit comments

Comments
 (0)