Refactor utils and organize routes/schema
This commit is contained in:
16
schema/category.model.js
Normal file
16
schema/category.model.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
// Database schema for an email message
|
||||
let Category = new Schema({
|
||||
name: {
|
||||
type: String
|
||||
},
|
||||
color: {
|
||||
type: String
|
||||
},
|
||||
}, {
|
||||
collection: 'categories'
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Category', Category);
|
||||
19
schema/message.model.js
Normal file
19
schema/message.model.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
// Database schema for an email message
|
||||
let Message = new Schema({
|
||||
name: {
|
||||
type: String
|
||||
},
|
||||
subject: {
|
||||
type: String
|
||||
},
|
||||
body: {
|
||||
type: String
|
||||
}
|
||||
}, {
|
||||
collection: 'messages'
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Message', Message);
|
||||
31
schema/post.model.js
Normal file
31
schema/post.model.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
// Database schema for an email message
|
||||
let Post = new Schema({
|
||||
title: {
|
||||
type: String
|
||||
},
|
||||
description: {
|
||||
type: String
|
||||
},
|
||||
author: {
|
||||
type: String
|
||||
},
|
||||
category: {
|
||||
type: Array
|
||||
},
|
||||
link: {
|
||||
type: String
|
||||
},
|
||||
date: {
|
||||
type: Date
|
||||
},
|
||||
photo: {
|
||||
type: String
|
||||
}
|
||||
}, {
|
||||
collection: 'posts'
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Post', Post);
|
||||
19
schema/session.model.js
Normal file
19
schema/session.model.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
// Database schema for a session
|
||||
let Session = new Schema({
|
||||
userId: {
|
||||
type: String
|
||||
},
|
||||
sessionId: {
|
||||
type: String
|
||||
},
|
||||
date: {
|
||||
type: Date
|
||||
}
|
||||
}, {
|
||||
collection: 'sessions'
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Session', Session);
|
||||
25
schema/user.model.js
Normal file
25
schema/user.model.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
// Database schema for a user
|
||||
let User = new Schema({
|
||||
email: {
|
||||
type: String
|
||||
},
|
||||
name: {
|
||||
type: String
|
||||
},
|
||||
password: {
|
||||
type: String
|
||||
},
|
||||
permission: {
|
||||
type: Number
|
||||
},
|
||||
favorites: {
|
||||
type: Array
|
||||
}
|
||||
}, {
|
||||
collection: 'users'
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('User', User);
|
||||
Reference in New Issue
Block a user