DailyCss

难点:置顶评论、数据库查询多重条件查询

查询Mongodb:

1
2
3
4
5
6
7
8
9
10
1. var whereStr = {"username":{$gte:""}};
//匹配>=""的username,即所有存在的username
2. var whereStr = {"id":id}
//简单的条件查询
3. var whereStr = {"id":id, "username":username}
var updateStr = {$set: {"status":"0"}};
var updateStr = {$set: {"time":time, "thing":thing}};
//查询符合条件的数据,更新一个数据或多个数据
4. var whereStr = {"$or":[{"username":"zxc110"}, {"username":"zxc111"}]}
//

跨域访问

1
2
3
4
5
6
7
8
9
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By",' 3.2.1')
res.header("Content-Type", "application/json;charset=utf-8");
next();
});
//实现跨域访问,可以让请求来自不同的域,需要写在所有绑定的路由前