-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from abianco3/test/init
set up initially testing specs
- Loading branch information
Showing
6 changed files
with
105 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
var mongoose = require('mongoose'); | ||
var connection = require('./index'); | ||
|
||
var EventSchema = mongoose.Schema({ | ||
username: String, | ||
description: String, | ||
start: String, | ||
end: String, | ||
location: String, | ||
phone: String, | ||
address: String, | ||
latitude: Number, | ||
longitude: Number, | ||
}); | ||
|
||
var Event = mongoose.model('Event', EventSchema); | ||
|
||
var UserSchema = mongoose.Schema({ | ||
userId: String, | ||
token: String, | ||
firstname: String, | ||
lastname: String, | ||
email: String | ||
}); | ||
|
||
var User = mongoose.model('User', UserSchema); | ||
|
||
var createUser = function(obj, callback) { | ||
User.create(obj, function(err, user) { | ||
if (err) { | ||
callback(err, null); | ||
} else { | ||
callback(null, user); | ||
console.log(user) | ||
} | ||
}); | ||
}; | ||
|
||
var findUser = function(userId, callback) { | ||
User.find({userId: userId}, function(err, user) { | ||
if (err) { | ||
callback(err, null); | ||
} else { | ||
callback(null, user); | ||
} | ||
}) | ||
} | ||
|
||
var selectAll = function(callback) { | ||
Event.find({}, function(err, events) { | ||
if (err) { | ||
callback(err, null); | ||
} else { | ||
callback(null, events) | ||
} | ||
}); | ||
}; | ||
|
||
var createEvent = function(obj, callback) { | ||
Event.create(obj, function(err, events) { | ||
if (err) { | ||
callback(err, null); | ||
} else { | ||
console.log('CREATE --->', events) | ||
callback(null, events); | ||
} | ||
}); | ||
}; | ||
|
||
var updateEvent = function(id, newInfo, callback) { | ||
Event.update(id, newInfo, function(err, events) { | ||
if (err) { | ||
callback(err, null); | ||
} else { | ||
console.log('UPDATE --->', events) | ||
callback(null, events); | ||
} | ||
}); | ||
}; | ||
|
||
var removeEvent = function(obj, callback) { | ||
Event.remove(obj, function(err, events) { | ||
if (err) { | ||
callback(err, null); | ||
} else { | ||
console.log('---> EVENT REMOVED!') | ||
callback(null, events); | ||
} | ||
}) | ||
}; | ||
|
||
module.exports.Event = Event; | ||
module.exports.selectAll = selectAll; | ||
module.exports.createUser = createUser; | ||
module.exports.createEvent = createEvent; | ||
module.exports.removeEvent = removeEvent; | ||
module.exports.updateEvent = updateEvent; | ||
module.exports.findUser = findUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var db = require('../database-mongo/models.js'); |