mirror of https://github.com/JoeBiellik/paste
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
345 B
JavaScript
20 lines
345 B
JavaScript
9 years ago
|
var mongoose = require('mongoose');
|
||
|
var shortId = require('short-mongo-id');
|
||
|
|
||
|
var paste = new mongoose.Schema({
|
||
|
paste: { type: String },
|
||
|
link: { type: String }
|
||
|
}, {
|
||
|
timestamps: true
|
||
|
});
|
||
|
|
||
|
paste.pre('save', function(next) {
|
||
|
if (this.isNew) {
|
||
|
this.link = shortId(this._id);
|
||
|
|
||
|
next();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
module.exports = mongoose.model('Paste', paste);
|