mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 06:32:11 +00:00
29 lines
725 B
JavaScript
29 lines
725 B
JavaScript
var mongoose = require('mongoose');
|
|
var Schema = require('mongoose').Schema;
|
|
|
|
|
|
var ExerciseStat = new Schema({
|
|
exerciseID: { type: Schema.ObjectId, ref: 'Exercise'},
|
|
modifier: {type: Number}
|
|
});
|
|
|
|
|
|
var UserSchema = new mongoose.Schema({
|
|
username: {type: String, unique: true, required: true},
|
|
name: String,
|
|
password: String,
|
|
is_admin: {type: Boolean, 'default': false },
|
|
is_imperial: {type: Boolean, 'default': false },
|
|
favorites: [{ type: Schema.ObjectId, ref: 'Exercises'}],
|
|
exercisestats: [ExerciseStat]
|
|
});
|
|
|
|
UserSchema.methods.recentworkouts = function(callback) {
|
|
return this.model('workout')
|
|
.find({userID: this._id})
|
|
//.sort('created_at', 1)
|
|
.limit(5)
|
|
.exec(callback);
|
|
};
|
|
|
|
module.exports = UserSchema; |