Skip to content

Commit 93bd929

Browse files
committed
mongoose
1 parent 800c3e9 commit 93bd929

4 files changed

Lines changed: 65 additions & 0 deletions

File tree

doc/day2_mongodb.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,28 @@ http://docs.mongodb.org/manual/core/crud-introduction/
195195
http://mongoosejs.com/docs/
196196

197197
http://www.tuicool.com/articles/ZVbYra
198+
199+
### 文档
200+
201+
Find the API docs [here](http://mongoosejs.com/docs/api.html), generated using [dox](http://github.com/visionmedia/dox).
202+
203+
cd到node_modules/mongoose里
204+
205+
```
206+
npm install
207+
node static.js
208+
```
209+
210+
这样就可以再本地看mongoose的api了
211+
212+
### 例子
213+
214+
每个例子都不错,必须熟悉
215+
216+
![](./images/mongoose.png)
217+
218+
node modules的好处是可以随时看到代码,是不是很爽啊?
219+
198220
## 高级
199221

200222
- gridfs

doc/day5_test.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,49 @@
1010
### db
1111
### http
1212

13+
```js
14+
var assert = require('chai').assert;
15+
var expect = require('chai').expect;
16+
require('chai').should();
17+
18+
var Utils = require('../index');
19+
20+
console.log(Utils)
21+
22+
var request = require('supertest')
23+
, express = require('express');
24+
25+
26+
describe('Utils.req', function(){
27+
describe('#get_value_from_body()', function(){
28+
it('should return Manny when get_value_from_body with key name', function(done){
29+
30+
var app = express();
31+
32+
app.post('/user', function(req, res){
33+
// mock req.body data
34+
req.body = { 'name': 'Manny', 'species': 'cat' };
35+
36+
var Manny = Utils.req.get_value_from_body(req, 'name');
37+
assert.equal(Manny, 'Manny');
38+
39+
var species = Utils.req.get_value_from_body(req, 'species');
40+
assert.equal(species, 'cat');
41+
42+
done();
43+
});
44+
45+
request(app)
46+
.post('/user')
47+
.set('contentType', 'application/x-www-form-urlencoded; charset=utf-8')
48+
.end(function(err, res){
49+
if (err) throw err;
50+
});
51+
52+
})
53+
})//end
54+
})
55+
```
1356

1457
## 了解supertest
1558

doc/demo/day1/.DS_Store

-6 KB
Binary file not shown.

doc/images/mongoose.png

114 KB
Loading

0 commit comments

Comments
 (0)