Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Tier2= new mongoose.Schema({
- 2A : {
- type: String
- },
- 2B: {
- type: String
- },
- 2C: {
- type: String
- }
- });
- var Tier1= new mongoose.Schema({
- 1A: {
- type: String
- },
- 1B : {
- type: String
- },
- 1C : {
- type: String
- },
- tier2: [Tier2]
- });
- var UserSchema = mongoose.Schema({
- username: {
- type: String,
- index:true
- },
- password: {
- type: String
- },
- email: {
- type: String
- },
- name: {
- type: String
- },
- tier1: [Tier1]
- });
- module.exports.createProgress = function(curUser, newProgress, callback){
- curUser.tier2.push(newProgress);
- curUser.save(function (err) {
- if (!err) console.log('Success!');
- });
- };
- module.exports.createTier2 = function(curUser, newTier2, curTier1, callback){
- curUser.curTier1.tier2.push(newTier2);
- curUser.save(function (err) {
- if (!err) console.log('Success!');
- });
- };
- module.exports.getProgress = function(username, 1A, 1B, 1C, callback){
- var query = {
- username: username,
- tier1: {
- $elemMatch: {
- 1A: 1A,
- 1B: 1B,
- 1C: 1C
- }
- }
- };
- User.findOne(query, callback);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement