Skip to content

Commit

Permalink
Add token db schema #23
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuscoto committed Jan 31, 2015
1 parent 24a59dd commit c914161
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions model/db.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var mongoose = require( 'mongoose' );
var Schema = mongoose.Schema;
var mongoose = require('mongoose')
var Schema = mongoose.Schema

var Users = new Schema({
user_id: String,
Expand All @@ -16,7 +16,7 @@ var Users = new Schema({
join_us: {type: Date, default: Date.now},
last_seen: {type: Date, default: Date.now},
unread: {type: Boolean, default: false},
});
})

var Notifications = new Schema({
src: String,
Expand All @@ -26,7 +26,7 @@ var Notifications = new Schema({
date: {type: Date, default: Date.now},
link: {type: String, default: null},
msg: {type: String, default: null}
});
})

var Challenges = new Schema({
name: String,
Expand All @@ -45,7 +45,7 @@ var Challenges = new Schema({
users: {type:[String], default: []},
admins: [String],
pulls: [Pulls]
});
})

var Pulls = new Schema({
_id: Schema.Types.ObjectId,
Expand All @@ -61,11 +61,16 @@ var Pulls = new Schema({
lines_inserted: {type: Number, default: 0},
lines_removed: {type: Number, default: 0},
files_changes: {type: Number, default: 0}
});
})

mongoose.model( 'Users', Users );
mongoose.model( 'Notifications', Notifications );
mongoose.model( 'Challenges', Challenges );
mongoose.model( 'Pulls', Pulls );
var Tokens = new Schema({
token: {type: String, default: null},
expired: {type: Date, default: null}
})

mongoose.connect( 'mongodb://localhost/rosedu-challenge' );
mongoose.model('Users', Users)
mongoose.model('Notifications', Notifications)
mongoose.model('Challenges', Challenges)
mongoose.model('Pulls', Pulls)

mongoose.connect('mongodb://localhost/rosedu-challenge')

0 comments on commit c914161

Please sign in to comment.