如何使用AWS Cloud9将内容commit到Github?
1. git init
2. git add
3. git commit -m
(4.) git remote add origin https://github.com/YuxuanZhao/ToysHub.git (只在第一次需要)
5. git push -u origin master
MongoDB 命令行控制
1. mongo
2. show dbs
3. toys_hub
4. use toys_hub
5. show collections
6. 增 db.toys.insert({name: "Zaku II", description: "blah"})
删 db.toys.remove({name: "Zaku II"})
改 db.toys.update({name: "Zaku II"}, {$set: (name: "Zaku III", description: "blah blah")})
查 db.toys.find({name: "Zaku II"})
想要在express里使用req.body,我们需要bodyParser
var bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({extended: true}));
使用Mongoose
var mongoose= require("mongoose");
//连接好mongo database
mongoose.connect("mongodb://localhost/toys_hub", {useNewUrlParser: true, useUnifiedTopology: true});
//新建toySchema确立格式
var toySchema = new mongoose.Schema({
name: String,
picture: String,
description: String
});
//新建model Toy来使用各种方法
var Toy = mongoose.model("Toy", toySchema);
//新建一个toy
Toy.create(newToy, function(err, newCreatedToy){
if (err){
console.log(err);
} else {
res.redirect("/toys");
}
});
//找到所有的toys
Toy.find({}, function(err, toys){
if (err){
console.log(err);
} else {
res.render("toys", {toys: toys});
}
});
使用partials
<%- include ('partials/header') %>
<%- include ('partials/footer') %>
计划新增的内容
1. header (nav) + footer
2. 基础的bootstrap美化
3. 做具体的id页面
4. 做一个增添comment的页面
5. 新加的 comment 能够自动加到id的页面
6. 可以删改toy id页面和comment
6. 做一个User model
7. 做User Authentication
8. 把User Authentication做到删改上
9. 做一个landing page
网友评论