diff --git a/NodeSample/models/article.js b/NodeSample/models/article.js index 7280f81..a4a61d5 100644 --- a/NodeSample/models/article.js +++ b/NodeSample/models/article.js @@ -1,24 +1,31 @@ -var util = require('util'); var mongoose = require('mongoose'); var Schema = mongoose.Schema; //定义article type实体对象模型 var articleTypeScheme = new Schema({ - articleType:String - ,describe:String - ,logoSrc:String + articleType: String, + describe: String, + logoSrc: String //,create_date: { type: Date, default: Date.now } }); //定义article details对象模型 var articleDetailScheme = new Schema({ - title:String - ,summary:String - ,content:String - ,create_date: { type: Date, default: Date.now } - ,refArticleId:{ type: Schema.Types.ObjectId, ref: 'articleType' } + title: String, + summary: String, + content: String, + create_date: { + type: Date, + default: Date.now + }, + refArticleId: { + type: Schema.Types.ObjectId, + ref: 'articleType' + } }); mongoose.model('articleType', articleTypeScheme); mongoose.model('articleDetail', articleDetailScheme); -module.exports.Schema =function (modelName){ - return{model:mongoose.model(modelName)}; -} +module.exports.Schema = function (modelName) { + return { + model: mongoose.model(modelName) + }; +} \ No newline at end of file diff --git a/NodeSample/models/todo.js b/NodeSample/models/todo.js index 7a4f08c..577fa98 100644 --- a/NodeSample/models/todo.js +++ b/NodeSample/models/todo.js @@ -5,21 +5,31 @@ * Time: 下午3:00 * To change this template use File | Settings | File Templates. */ -var util = require('util'); var mongoose = require('mongoose'); var Schema = mongoose.Schema; //定义article type实体对象模型 var todoTypeScheme = new Schema({ - taskType:String, - status:String, - title:String, - project:String, - startDate: { type: Date, default: Date.now }, - endDate: { type: Date, default: Date.now }, - priority:{type:int,default:0} + taskType: String, + status: String, + title: String, + project: String, + startDate: { + type: Date, + default: Date.now + }, + endDate: { + type: Date, + default: Date.now + }, + priority: { + type: int, + default: 0 + } }); mongoose.model('todoManager', todoTypeScheme); -module.exports.Schema =function (modelName){ - return{model:mongoose.model(modelName)}; -} +module.exports.Schema = function (modelName) { + return { + model: mongoose.model(modelName) + }; +} \ No newline at end of file diff --git a/NodeSample/models/user.js b/NodeSample/models/user.js index 08c148a..8bbc391 100644 --- a/NodeSample/models/user.js +++ b/NodeSample/models/user.js @@ -1,14 +1,18 @@ -var util = require('util'); var mongoose = require('mongoose'); var Schema = mongoose.Schema; var userSchema = new Schema({ - userName:String, - password:String, - email:String, - create_date: { type: Date, default: Date.now } + userName: String, + password: String, + email: String, + create_date: { + type: Date, + default: Date.now + } }); //访问todo对象模型 mongoose.model('user', userSchema); -module.exports.Schema =function (modelName){ - return{model:mongoose.model(modelName)}; -} +module.exports.Schema = function (modelName) { + return { + model: mongoose.model(modelName) + }; +} \ No newline at end of file