Files
roboto-promoto/lib/models/promotion.js
Fergal Moran 2fade3342c Test cleanup
2014-03-20 14:53:22 +00:00

22 lines
568 B
JavaScript

'use strict';
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
/** Promotion Schema */
var PromotionSchema = new Schema({
created: { type: Date, default: Date.now },
title: { type: String, default: '', trim: true, required: true },
user: { type: Schema.ObjectId, ref: 'User', required: true }
});
/* Indexes */
PromotionSchema.index({title: 1, user: 1}, {unique: true});
/* Operations */
PromotionSchema.statics.findByTitle = function(title, cb){
this.findOne({title: title}, cb);
};
mongoose.model('Promotion', PromotionSchema);