用的都是我熟悉的技术,看了别人的开发过程,自己也学到了一些新的知识
生成配置文件
开发结束后,可以使用bower init
来生成前端的配置文件。
不过在bower install *时已经生成了。
可以使用 npm init
来生成后端的配置文件
不过使用
express -e *
时,也会生成package.json。npm install * --save才会保存到package.json,开发结束后,把package.json删了,重新生成一次。
删除
可以使用type: delete
;
之前也知道,但还一直使用$.get来做。
表单提交
body-parser, extend=true;
form name=movie[title];
可以直接取出req.body.movie;
views
修改app.js,把router指向的view目录改为views/pages
在views中新建includes和pages
mongoose schema
//保存之前的操作
MoiveSchema.pre('save', funciton(){});
// 把一系列的方法抽象出来
MovieSchema.statics = {}
日期格式化
npm install moment
在app.js中,app.locals.moment = require('moment');
早list.ejs中,<td><%= moment(movie.meta.updateAt).format('MM/DD/YYYY') %></td>
if()判断
false 0 undefined null NaN '' => false
true 1 {} [] '0' => true
属性复制
//复制**source**对象中的所有属性覆盖到**destination**对象上,并且返回 **destination** 对象. 复制是按顺序的, 所以后面的对象属性会把前面的对象属性覆盖掉(如果有重复).
_movie = _.extend(movie, movie_obj);