Update: Models

This commit is contained in:
Yûki VACHOT 2021-12-01 05:52:34 +01:00
parent 70ca726122
commit 002f79851a
10 changed files with 55 additions and 71 deletions

View file

@ -1,9 +1,14 @@
module.exports = mongoose => { module.exports = mongoose => {
let schema = mongoose.Schema({ let schema = mongoose.Schema({
url: String, userId: String,
title: String, title: String,
description: String, images: Array,
views: Number url: String,
interests: Array,
comment: String,
views: Array,
isVisible: Boolean,
isActive: Boolean
}, },
{ timestamps: true } { timestamps: true }
); );
@ -14,5 +19,5 @@ module.exports = mongoose => {
return object; return object;
}); });
return mongoose.model("video", schema); return mongoose.model("ads", schema);
}; };

View file

@ -1,8 +1,9 @@
module.exports = mongoose => { module.exports = mongoose => {
let schema = mongoose.Schema({ let schema = mongoose.Schema({
userId: String, userId: String,
videoIds: Array,
name: String, name: String,
videos: Array isActive: Boolean
}, },
{ timestamps: true } { timestamps: true }
); );
@ -13,5 +14,5 @@ module.exports = mongoose => {
return object; return object;
}); });
return mongoose.model("playlist", schema); return mongoose.model("playlists", schema);
}; };

View file

@ -1,14 +1,15 @@
const roles = require("../config/role.config"); const roles = require("../../config/role.config");
module.exports = mongoose => { module.exports = mongoose => {
let schema = mongoose.Schema({ let schema = mongoose.Schema({
login: String, email: String,
hashPass: String, // WARNING: We don't want to send back the hashPass hashPass: String, // WARNING: We don't want to send back the hashPass
mail: String, login: String,
role: { role: {
type: Object, type: Object,
default: roles.User default: roles.User
}, },
company: String,
profilePictureUrl: { profilePictureUrl: {
type: String, type: String,
default: null default: null
@ -25,10 +26,15 @@ module.exports = mongoose => {
type: Array, type: Array,
default: null default: null
}, },
active: { isActive: {
type: Boolean, type: Boolean,
default: true default: true
} },
isAccepted: {
type: Boolean,
default: false
},
lastConnexion: Date
}, },
{ timestamps: true } { timestamps: true }
); );
@ -39,5 +45,5 @@ module.exports = mongoose => {
return object; return object;
}); });
return mongoose.model("user", schema); return mongoose.model("users", schema);
}; };

View file

@ -1,9 +1,11 @@
module.exports = mongoose => { module.exports = mongoose => {
let schema = mongoose.Schema({ let schema = mongoose.Schema({
images: [], userId: String,
text: String, videoId: String,
subjectTarget: [], source: String,
seen: Number tags: Array,
interest: String,
watchedDates: Array
}, },
{ timestamps: true } { timestamps: true }
); );
@ -14,5 +16,5 @@ module.exports = mongoose => {
return object; return object;
}); });
return mongoose.model("ad", schema); return mongoose.model("videos", schema);
}; };

View file

@ -1,15 +0,0 @@
module.exports = mongoose => {
let schema = mongoose.Schema({
user: Object
},
{ timestamps: true }
);
schema.method("toJSON", function() {
const { __v, _id, ...object } = this.toObject();
object.id = _id;
return object;
});
return mongoose.model("history", schema);
};

View file

@ -1,18 +0,0 @@
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);
};

View file

@ -11,10 +11,9 @@ if(typeof process.env.NODE_ENV !== 'undefined' && process.env.NODE_ENV === 'prod
db.url = dbConfig.devUrl; db.url = dbConfig.devUrl;
} }
db.users = require("./user.model")(mongoose); db.users = require("./database/users.model")(mongoose);
db.playlists = require("./playlist.model")(mongoose); db.playlists = require("./database/playlists.model")(mongoose);
db.ads = require("./ad.model")(mongoose); db.videos = require("./database/videos.model")(mongoose);
db.histories = require("./history.model")(mongoose); db.ads = require("./database/ads.model")(mongoose);
module.exports = db; module.exports = db;

View file

@ -0,0 +1,10 @@
class Image {
constructor(base64, url, description, type){
this.base64 = base64;
this.url = url;
this.description = description;
this.type = type;
}
}
module.exports = Image;

View file

@ -0,0 +1,10 @@
class Token {
constructor(id, email, profileImageUrl, role){
this.id = id;
this.email = email;
this.profileImageUrl = profileImageUrl;
this.role = role;
}
}
module.exports = Token;

View file

@ -1,16 +0,0 @@
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);
};