somewhere
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
const mongoose = require('mongoose')
|
||||
const paginate = require('mongoose-paginate-v2')
|
||||
|
||||
function image(img) {
|
||||
return '/uploads/images/downloads/' + img
|
||||
}
|
||||
|
||||
function file(file) {
|
||||
return '/uploads/apps/' + file
|
||||
}
|
||||
|
||||
const DownloadFilesSchema = mongoose.Schema({
|
||||
_creator: { type: mongoose.ObjectId, ref: 'User' },
|
||||
name: String,
|
||||
os: {
|
||||
type: String,
|
||||
enum: ['windows', 'linux', 'mac', 'android', 'ios']
|
||||
},
|
||||
file: { type: String, get: file }
|
||||
})
|
||||
|
||||
const DownloadSchema = mongoose.Schema({
|
||||
_creator: { type: mongoose.ObjectId, ref: 'User' },
|
||||
title: String,
|
||||
short_description: String,
|
||||
description: String,
|
||||
image: { type: String, get: image },
|
||||
category: mongoose.ObjectId,
|
||||
files: [DownloadFilesSchema]
|
||||
})
|
||||
DownloadSchema.plugin(paginate)
|
||||
|
||||
module.exports = mongoose.model('Download', DownloadSchema)
|
||||
@@ -0,0 +1,8 @@
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const DownloadCategorySchema = mongoose.Schema({
|
||||
_creator: { type: mongoose.ObjectId, ref: 'User' },
|
||||
name: String
|
||||
})
|
||||
|
||||
module.exports = mongoose.model('DownloadCategory', DownloadCategorySchema)
|
||||
Reference in New Issue
Block a user