---|main| Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
var mongoose = require('mongoose');
|
||||
var uniqueValidator = require('mongoose-unique-validator');
|
||||
|
||||
var CurrencySchema = new mongoose.Schema({
|
||||
ordering: Number,
|
||||
code: { type: String, upercase: true, unique: true },
|
||||
title: String
|
||||
}, {timestamps: true, toJSON: {virtuals: true}});
|
||||
|
||||
CurrencySchema.plugin(uniqueValidator, { message: 'is already taken' });
|
||||
|
||||
CurrencySchema.methods.toJSONFor = function(){
|
||||
return {
|
||||
ordering: this.ordering,
|
||||
code: this.code,
|
||||
title: this.title
|
||||
};
|
||||
};
|
||||
|
||||
mongoose.model('Currency', CurrencySchema, 'currencies');
|
||||
Reference in New Issue
Block a user