Update: Models
This commit is contained in:
parent
70ca726122
commit
002f79851a
10 changed files with 55 additions and 71 deletions
|
|
@ -1,9 +1,14 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
url: String,
|
||||
userId: String,
|
||||
title: String,
|
||||
description: String,
|
||||
views: Number
|
||||
images: Array,
|
||||
url: String,
|
||||
interests: Array,
|
||||
comment: String,
|
||||
views: Array,
|
||||
isVisible: Boolean,
|
||||
isActive: Boolean
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
|
@ -14,5 +19,5 @@ module.exports = mongoose => {
|
|||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("video", schema);
|
||||
return mongoose.model("ads", schema);
|
||||
};
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
userId: String,
|
||||
videoIds: Array,
|
||||
name: String,
|
||||
videos: Array
|
||||
isActive: Boolean
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
|
@ -13,5 +14,5 @@ module.exports = mongoose => {
|
|||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("playlist", schema);
|
||||
return mongoose.model("playlists", schema);
|
||||
};
|
||||
|
|
@ -1,14 +1,15 @@
|
|||
const roles = require("../config/role.config");
|
||||
const roles = require("../../config/role.config");
|
||||
|
||||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
login: String,
|
||||
email: String,
|
||||
hashPass: String, // WARNING: We don't want to send back the hashPass
|
||||
mail: String,
|
||||
login: String,
|
||||
role: {
|
||||
type: Object,
|
||||
default: roles.User
|
||||
},
|
||||
company: String,
|
||||
profilePictureUrl: {
|
||||
type: String,
|
||||
default: null
|
||||
|
|
@ -25,10 +26,15 @@ module.exports = mongoose => {
|
|||
type: Array,
|
||||
default: null
|
||||
},
|
||||
active: {
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
isAccepted: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
lastConnexion: Date
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
|
@ -39,5 +45,5 @@ module.exports = mongoose => {
|
|||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("user", schema);
|
||||
return mongoose.model("users", schema);
|
||||
};
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
images: [],
|
||||
text: String,
|
||||
subjectTarget: [],
|
||||
seen: Number
|
||||
userId: String,
|
||||
videoId: String,
|
||||
source: String,
|
||||
tags: Array,
|
||||
interest: String,
|
||||
watchedDates: Array
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
|
@ -14,5 +16,5 @@ module.exports = mongoose => {
|
|||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("ad", schema);
|
||||
return mongoose.model("videos", schema);
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -11,10 +11,9 @@ if(typeof process.env.NODE_ENV !== 'undefined' && process.env.NODE_ENV === 'prod
|
|||
db.url = dbConfig.devUrl;
|
||||
}
|
||||
|
||||
db.users = require("./user.model")(mongoose);
|
||||
db.playlists = require("./playlist.model")(mongoose);
|
||||
db.ads = require("./ad.model")(mongoose);
|
||||
db.histories = require("./history.model")(mongoose);
|
||||
|
||||
db.users = require("./database/users.model")(mongoose);
|
||||
db.playlists = require("./database/playlists.model")(mongoose);
|
||||
db.videos = require("./database/videos.model")(mongoose);
|
||||
db.ads = require("./database/ads.model")(mongoose);
|
||||
|
||||
module.exports = db;
|
||||
|
|
|
|||
10
app-backend/models/objects/image.model.js
Normal file
10
app-backend/models/objects/image.model.js
Normal 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;
|
||||
10
app-backend/models/objects/token.model.js
Normal file
10
app-backend/models/objects/token.model.js
Normal 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;
|
||||
|
|
@ -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);
|
||||
};
|
||||
Reference in a new issue