Add playlist, video and ad skeleton
This commit is contained in:
parent
e87c4bb146
commit
5f73ec72bc
20 changed files with 414 additions and 65 deletions
18
backend/app/models/ad.model.js
Normal file
18
backend/app/models/ad.model.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
images: [],
|
||||
text: String,
|
||||
subjectTarget: [],
|
||||
seen: Number
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("ad", schema);
|
||||
};
|
||||
18
backend/app/models/image.model.js
Normal file
18
backend/app/models/image.model.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
base64: String,
|
||||
fromUrl: String,
|
||||
description: String,
|
||||
type: Number
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("image", schema);
|
||||
};
|
||||
|
|
@ -7,5 +7,9 @@ const db = {};
|
|||
db.mongoose = mongoose;
|
||||
db.url = dbConfig.url;
|
||||
db.users = require("./user.model")(mongoose);
|
||||
db.playlists = require("./playlist.model")(mongoose);
|
||||
db.videos = require("./video.model")(mongoose);
|
||||
db.ads = require("./ad.model")(mongoose);
|
||||
db.images = require("./image.model")(mongoose);
|
||||
|
||||
module.exports = db;
|
||||
|
|
|
|||
16
backend/app/models/playlist.model.js
Normal file
16
backend/app/models/playlist.model.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
name: String,
|
||||
videos: []
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("playlist", schema);
|
||||
};
|
||||
16
backend/app/models/subjectTarget.model.js
Normal file
16
backend/app/models/subjectTarget.model.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
name: String,
|
||||
keywords: []
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("subjectTarget", schema);
|
||||
};
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
const roles = require("../config/role.config");
|
||||
|
||||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
login: String,
|
||||
|
|
@ -5,8 +7,9 @@ module.exports = mongoose => {
|
|||
mail: String,
|
||||
role: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
default: roles.User
|
||||
},
|
||||
playlists: []
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
|
|
|||
18
backend/app/models/video.model.js
Normal file
18
backend/app/models/video.model.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
url: String,
|
||||
title: String,
|
||||
description: String,
|
||||
views: Number
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("video", schema);
|
||||
};
|
||||
Reference in a new issue