forked from cs4241-21a/a3-persistence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.js
26 lines (23 loc) · 817 Bytes
/
models.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const mongoose = require('mongoose');
const findOrCreate = require('mongoose-findorcreate');
const userSchema = mongoose.Schema({
username: {type: String, required: false},
password: {type: String, required: false},
githubId: {type: String, required: false}
},
{versionKey: false});
userSchema.plugin(findOrCreate);
const userModel = mongoose.model('User', userSchema, 'users');
const flightSchema = mongoose.Schema({
flightNum: {type: String},
depAirport: {type: String},
arrAirport: {type: String},
date: {type: String},
owner: {type: String}
},
{versionKey: false});
const flightModel = mongoose.model('Flight', flightSchema, 'flights');
module.exports = {
User: userModel,
Flight: flightModel
};