項目服務端編程語言node,前端js,數據庫mongodb, 開發工具用webstorm。html
npm install express-generator -g
server.listen(port,function () {
db.getConnect()
});
1 //引入數據庫操做模塊 2 var autoIncrement = require('mongoose-auto-increment')//自增模塊 3 ; 4 var mongoose = require("mongoose"); 5 var errors = require('../errors'); 6 var Schema = mongoose.Schema; 7 var utils = require('../utils'); 8 //聲明User Schema結構 9 var userSchema = new Schema({ 10 phoneNo: {type: String, default: ""}, 11 password: {type: String, default: ""}, 12 nickname: {type: String, default: ""}, 13 icon: {type: String, default: ""}, 14 address: {type: String, default: ""}, 15 age: {type: Number, default: 0}, 16 gender: {type: String, default: ""}, 17 regTime: {type: Number, default: Date.now}, 18 latestLogin: {type: Number, default: 0}, 19 isFrozen: {type: Boolean, default: false}, 20 realName: {type: String, default: ""}, 21 identity: {type: String, default: "patient"} 22 }); 23 24 //初始化自增模塊 25 autoIncrement.initialize(mongoose.connection); 26 27 //自增鍵 28 userSchema.plugin(autoIncrement.plugin, { 29 //自增ID配置 30 model: 'User', 31 field: '_id', 32 startAt: 1, 33 incrementBy: 1 34 }); 35 36 37 //將User類給予接口 38 var User = mongoose.model('User', userSchema); 39 40 module.exports = User;
app.use('/user', require('./routes/user')); app.use('/consignee', require('./routes/consignee')); app.use('/hospital', require('./routes/hospital')); app.use('/order', require('./routes/order')); app.use('/comment', require('./routes/comment')); app.use('/record', require('./routes/record')); app.use('/file', require('./routes/file'));//文件上傳
至此,一個node項目框架就搭建完成了。前端