Refactoring et ajout de routes Hero Wars
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
var mongoose = require('mongoose');
|
||||
var uniqueValidator = require('mongoose-unique-validator');
|
||||
|
||||
var HWClanSchema = new mongoose.Schema({
|
||||
id: { type: String, unique: true },
|
||||
country: String,
|
||||
description: String,
|
||||
disbanding: Boolean,
|
||||
frameId: Number,
|
||||
icon: {
|
||||
flagColor1: Number,
|
||||
flagColor2: Number,
|
||||
flagShape: Number,
|
||||
iconColor: Number,
|
||||
iconShape: Number,
|
||||
},
|
||||
level: String,
|
||||
members: [{ type: mongoose.Schema.Types.ObjectId, ref: 'HWMember' }],
|
||||
membersCount: Number,
|
||||
minLevel: String,
|
||||
ownerId: String,
|
||||
/*roleNames: { type: mongoose.Schema.Types.ObjectId, ref: 'HWClanRoles' },*/
|
||||
serverId: String,
|
||||
title: String,
|
||||
topActivity: String,
|
||||
topDungeon: String,
|
||||
author: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }
|
||||
}, {timestamps: true, toJSON: {virtuals: true}});
|
||||
|
||||
HWClanSchema.plugin(uniqueValidator, { message: 'is already taken' });
|
||||
|
||||
HWClanSchema.methods.toJSONFor = function() {
|
||||
return {
|
||||
id: this.id,
|
||||
country: this.country,
|
||||
description: this.description,
|
||||
disbanding: this.disbanding,
|
||||
frameId: this.frameId,
|
||||
icon: this.icon,
|
||||
level: this.level,
|
||||
members: this.members,
|
||||
membersCount: this.membersCount,
|
||||
minLevel: this.minLevel,
|
||||
ownerId: this.ownerId,
|
||||
serverId: this.serverId,
|
||||
title: this.title,
|
||||
topActivity: this.topActivity,
|
||||
topDungeon: this.topDungeon,
|
||||
createdAt: this.createdAt,
|
||||
updatedAt: this.updatedAt,
|
||||
author: this.author.toJSONFor()
|
||||
};
|
||||
};
|
||||
|
||||
mongoose.model('HWClan', HWClanSchema);
|
||||
Reference in New Issue
Block a user