mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 06:32:11 +00:00
migrating repo to Bodyrep org
This commit is contained in:
6
data/models/exercise.js
Normal file
6
data/models/exercise.js
Normal file
@@ -0,0 +1,6 @@
|
||||
var mongoose = require('mongoose');
|
||||
var ExerciseSchema = require('../schemas/exerise');
|
||||
|
||||
var Exercise = mongoose.model('Exercise', ExerciseSchema);
|
||||
|
||||
module.exports = Exercise;
|
||||
6
data/models/user.js
Normal file
6
data/models/user.js
Normal file
@@ -0,0 +1,6 @@
|
||||
var mongoose = require('mongoose');
|
||||
var UserSchema = require('../schemas/user');
|
||||
|
||||
var User = mongoose.model('User', UserSchema);
|
||||
|
||||
module.exports = User;
|
||||
6
data/models/workout.js
Normal file
6
data/models/workout.js
Normal file
@@ -0,0 +1,6 @@
|
||||
var mongoose = require('mongoose');
|
||||
var workoutSchema = require('../schemas/workout');
|
||||
|
||||
var workout = mongoose.model('workout', workoutSchema);
|
||||
|
||||
module.exports = workout;
|
||||
20
data/schemas/exercise.js
Normal file
20
data/schemas/exercise.js
Normal file
@@ -0,0 +1,20 @@
|
||||
var Schema = require('mongoose').Schema;
|
||||
|
||||
var Datafield = new Schema({
|
||||
datafieldname: { type: String},
|
||||
datafieldtype: { type: String}
|
||||
});
|
||||
|
||||
|
||||
var exerciseSchema = new Schema({
|
||||
name: String,
|
||||
type: String,
|
||||
description: String,
|
||||
difficulty: Number,
|
||||
musclearray: [Number],
|
||||
keywords: [String],
|
||||
alternatives: [ids],
|
||||
datafields: [Datafield]
|
||||
});
|
||||
|
||||
module.exports = workoutSchema;
|
||||
18
data/schemas/user.js
Normal file
18
data/schemas/user.js
Normal file
@@ -0,0 +1,18 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
var UserSchema = new mongoose.Schema({
|
||||
username: {type: String, unique: true, required: true},
|
||||
name: String,
|
||||
password: String,
|
||||
is_admin: {type: Boolean, 'default': false }
|
||||
});
|
||||
|
||||
UserSchema.methods.recentworkouts = function(callback) {
|
||||
return this.model('workout')
|
||||
.find({author: this._id})
|
||||
//.sort('created_at', 1)
|
||||
.limit(5)
|
||||
.exec(callback);
|
||||
};
|
||||
|
||||
module.exports = UserSchema;
|
||||
29
data/schemas/workout.js
Normal file
29
data/schemas/workout.js
Normal file
@@ -0,0 +1,29 @@
|
||||
var Schema = require('mongoose').Schema;
|
||||
|
||||
|
||||
var Split = new Schema({
|
||||
reps: { type: String},
|
||||
weight: { type: String}
|
||||
});
|
||||
|
||||
|
||||
var Element = new Schema({
|
||||
ExerciseID: { type: String},
|
||||
splits: [Split]
|
||||
});
|
||||
|
||||
|
||||
var workoutSchema = new Schema({
|
||||
|
||||
userID: { type: Schema.ObjectId, ref: 'User', required: true },
|
||||
workoutDate: { type: Date, 'default': Date.now },
|
||||
workoutTime: { type: Date, 'default': Date.now },
|
||||
privacySetting: { type: Number},
|
||||
Notes: { type: String},
|
||||
templateID: { type: Schema.ObjectId, ref: 'Template'},
|
||||
circuits: [Number],
|
||||
elements: [Element]
|
||||
|
||||
});
|
||||
|
||||
module.exports = workoutSchema;
|
||||
29
data/schemas/workout_new.js
Normal file
29
data/schemas/workout_new.js
Normal file
@@ -0,0 +1,29 @@
|
||||
var Schema = require('mongoose').Schema;
|
||||
|
||||
|
||||
var Split = new Schema({
|
||||
reps: { type: String},
|
||||
weight: { type: String}
|
||||
});
|
||||
|
||||
|
||||
var Element = new Schema({
|
||||
ExerciseID: {type: String} ,
|
||||
splits: [Split]
|
||||
});
|
||||
|
||||
|
||||
var workoutSchema = new Schema({
|
||||
|
||||
userID: { type: Schema.ObjectId, ref: 'User', required: true },
|
||||
workoutDate: { type: Date, 'default': Date.now },
|
||||
workoutTime: { type: Date, 'default': Date.now },
|
||||
privacySetting: { type: Number},
|
||||
Notes: { type: String},
|
||||
templateID: { type: Schema.ObjectId, ref: 'Template'},
|
||||
circuits: [Number],
|
||||
elements: [Element]
|
||||
|
||||
});
|
||||
|
||||
module.exports = workoutSchema;
|
||||
Reference in New Issue
Block a user