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.
paste/models/paste.js

20 lines
345 B
JavaScript

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);