Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose = require('mongoose');
- var Schema = mongoose.Schema({
- name: String,
- balance: {},
- description: String,
- author: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
- moderators: [{type: mongoose.Schema.Types.ObjectId, sparse: true, ref: 'User'}],
- url: {type: String, unique: true, sparse: true, trim: true},
- avatarUrl: {type: String, default: '/assets/img/groups/avatar.png'},
- });
- Schema.methods.create = function(obj, user, sd) {
- this.author = user._id;
- this.balance = {};
- this.moderators = [user._id];
- this.name = obj.name;
- this.balance[user._id] = [];
- this.avatarUrl = obj.avatarUrl || '/assets/img/groups/avatar.png'
- this.balance['item'] = 0
- }
- module.exports = mongoose.model('Group', Schema);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement