Skip to content

Commit

Permalink
Added temp schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
widmonstertony committed Apr 7, 2019
1 parent 1b88f6b commit c8c0f1f
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 70 deletions.
70 changes: 0 additions & 70 deletions src/api/leasing.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,6 @@
// TODO: Turn APIs into NO RES REQ function calls!

const Mongo = require('keeling-js/lib/mongo')
<<<<<<< HEAD
const ObjectId = require('./objectId')
const Leasing = Mongo.db.collection('leasing')

module.exports = {
insert (userId, callback, error) {
Leasing.insertOne({
'user_id': ObjectId(userId),
'status': 0
}, function (err, result) {
if (err) {
error(new Error('Error adding new house ' + userId + ': ' + err))
} else {
callback(result['insertedId'])
}
})
},

findByCriteria (criteria, callback, error) {
Leasing.find({
...criteria,
'status': 1
}).toArray(function (err, result) {
if (err) {
error(err)
} else {
callback(result)
}
})
},

getLeasing (leasingId, callback, error) {
Leasing.findOne({
'_id': ObjectId(leasingId)
}).toArray(function (err, result) {
if (err) {
error(err)
} else {
callback(result[0])
}
})
},

updateOne (leasingId, criteria, callback, error) {
Leasing.updateOne({
'_id': ObjectId(leasingId)
}, criteria, (err, result) => {
if (err) {

} else {

}
})
},

setavailable () {

},

setUnavailable () {

}
}
/**
* req.body.username,
* req.body.password
*/
/*
=======
const ObjectId = require('mongodb').ObjectId
const Leasing = Mongo.db.collection('leasing')

Expand Down Expand Up @@ -103,7 +34,6 @@ module.exports = {
* req.body.password
*/
/*
>>>>>>> b42562a3c439ccb2e2f98aaa7830ea201db6f4c8
"add_one": function (req, res) {
var userId = req.body.userId;
var start_date = req.body.start_date;
Expand Down
14 changes: 14 additions & 0 deletions src/models/Complex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mongoose = require('mongoose');

const ComplexSchema = new mongoose.Schema({
ComplexId: {
type: Number,
default: -1
},
ComplexName: {
type: String,
default: ''
}
});

module.exports = mongoose.model('Complex', ComplexSchema);
58 changes: 58 additions & 0 deletions src/models/Leasing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const mongoose = require('mongoose');

const LeasingSchema = new mongoose.Schema({
user_id: {
type: String,
default: ''
},
start_date: {
type: Date,
default: Date.now()
},
end_date: {
type: Date,
default: Date.now()
},
complex_id: {
type: String,
default: ''
},
apt_bedroom_amount: {
type: String,
default: ''
},
apt_bathroom_amount: {
type: String,
default: ''
},
room_avail: {
type: String,
default: ''
},
gender_req: {
type: String,
default: ''
},
user_description: {
type: String,
default: ''
},
facility: {
type: String,
default: ''
},
notice: {
type: String,
default: ''
},
location: {
type: String,
default: ''
},
img_url: {
type: String,
default: ''
},
});

module.exports = mongoose.model('Leasing', LeasingSchema);
22 changes: 22 additions & 0 deletions src/models/User.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema({
username: {
type: String,
default: ""
},
email: {
type: String,
default: ""
},
real_name: {
type: String,
default: ""
},
qr_code: {
type: data,
default: ""
},
});

module.exports = mongoose.model("User", UserSchema);

0 comments on commit c8c0f1f

Please sign in to comment.