{"size": 514, "ext": "js", "max_stars_repo_path": "models/Form.js", "max_stars_repo_name": "jordancappy/jorder", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "models/Form.js", "max_issues_repo_name": "jordancappy/jorder", "max_issues_repo_issues_event_min_datetime": "2015-07-08T23:06:40.000Z", "max_issues_repo_issues_event_max_datetime": "2015-07-08T23:06:40.000Z", "max_forks_repo_path": "models/Form.js", "max_forks_repo_name": "jordancappy/jorder", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 19.7692307692, "max_line_length": 52, "alphanum_fraction": 0.6906614786}
var mongoose = require('mongoose');
var Schema = mongoose.Schema;


var formSchema = new Schema({
	name: String,
	meta: {color: String},
	pages:[{type: Schema.Types.ObjectId, ref: 'Page'}],
	created_at: Date,
	lastUpdated_at: Date
});

formSchema.pre('save', function(next){
	var currentDate = new Date();

	if (!meta.color) this.meta.color = "blue";
	
	this.lastUpdated_at = currentDate;
	
	if(!this.created_at)
		this.created_at = currentDate;
	
	next();
});

module.exports = mongoose.model('Form', formSchema);