Commit ebce8afa authored by Sang D NGO's avatar Sang D NGO
Browse files

add models

parent 7b8c60e1
'use strict';
// arguments: dependencies
module.exports = function() {
// const model = require('./YOUR_MODEL')(dependencies);
module.exports = function(dependencies) {
const Proposal = require('./proposal')(dependencies);
const Review = require('./review')(dependencies);
return {
// model
Proposal,
Review
};
};
module.exports = function(dependencies) {
const mongoose = dependencies('db').mongo.mongoose;
const Schema = mongoose.Schema;
const ObjectId = mongoose.Schema.ObjectId;
const schema = new Schema({
creator: { type: ObjectId, ref: 'User', index: true, required: true },
type: { type: String, enum: ['A1', 'A2', 'A3'], required: true },
formData: { type: String, required: true },
status: { type: String, enum: ['PENDING', 'REVIEWING', 'ACCEPTED', 'REJECTED'], default: 'PENDING' },
reviewers: [{ type: ObjectId, ref: 'User' }]
}, { timestamps: true });
return mongoose.model('MostProposal', schema);
};
module.exports = function(dependencies) {
const mongoose = dependencies('db').mongo.mongoose;
const Schema = mongoose.Schema;
const ObjectId = mongoose.Schema.ObjectId;
const AttachmentSchema = new mongoose.Schema({
_id: {type: ObjectId, required: true},
name: {type: String, required: true},
contentType: {type: String, required: true},
length: {type: Number, required: true}
});
const schema = new Schema({
userId: { type: ObjectId, ref: 'User', index: true, required: true },
proposalId: { type: ObjectId, ref: 'MostProposal' },
status: { type: String, enum: ['PENDING', 'ACCEPTED', 'REJECTED'], default: 'PENDING' },
attachments: {type: [AttachmentSchema], required: false}
}, { timestamps: true });
return mongoose.model('MostReview', schema);
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment