mirror of
https://github.com/fergalmoran/roboto-promoto.git
synced 2025-12-22 09:37:37 +00:00
Initial Commit
This commit is contained in:
22
lib/models/promotion.js
Normal file
22
lib/models/promotion.js
Normal file
@@ -0,0 +1,22 @@
|
||||
'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});
|
||||
var _model = mongoose.model('Promotion', PromotionSchema);
|
||||
|
||||
/* Operations */
|
||||
PromotionSchema.statics.findByTitle = function(title, cb){
|
||||
console.log("findByTitle: " + title);
|
||||
_model.findOne({title: title}, cb);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user