Skip to content

Commit

Permalink
fix(*): update article be
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseaCodes committed Aug 31, 2023
1 parent ca02b2c commit 6114661
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions controllers/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function getArticleByID(req, res) {
async function createArticle(req, res) {
try {

const { article_id, title, subtitle, markdown, description, images, category, dev, medium } = req.body;
const { article_id, title, subtitle, markdown, description, images, category, dev, medium, postedBy } = req.body;

if (!images) {

Expand All @@ -80,7 +80,7 @@ async function createArticle(req, res) {
// }

const newArticle = new Articles({
article_id, title, subtitle, markdown, description, images, category
article_id, title, subtitle, markdown, description, images, category, postedBy
})

try {
Expand Down
36 changes: 24 additions & 12 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ const userSchema = new mongoose.Schema({
required: true,
trim: true
},
username: {
type: String,
},
aboutMe: {
type: String,
},
projects: {
type: [String],
},
email: {
type: String,
required: true,
Expand All @@ -21,7 +30,7 @@ const userSchema = new mongoose.Schema({
default: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT0k6I8WItSjK0JTttL3FwACOA6yugI29xvLw&usqp=CAU",
},
work : {
type: Array,
type: [String],
},
title: {
type: String,
Expand All @@ -32,17 +41,21 @@ const userSchema = new mongoose.Schema({
trim: true
},
education : {
type: Array,
type: [String],
},
skills : {
type: Array,
type: [String],
default: []
},
sociallMedia : {
type: Array,
socialMedia : {
type: [String],
},
socialMediaHandles: {
type: Map,
of: String
},
websites : {
type: Array,
type: [String],
},
location : {
type: String,
Expand All @@ -52,21 +65,20 @@ const userSchema = new mongoose.Schema({
type: Number,
default: 0
},
// articles: [{
// type: mongoose.Schema.Types.ObjectId,
// ref: 'Articles'
// }],
articles: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Articles'
}],
cart: {
type: Array,
default: []
}
}, {
timestamps: true
})
}, { strict: false })


const Users = mongoose.model('Users', userSchema);

// Users.createIndexes();

export default Users;

0 comments on commit 6114661

Please sign in to comment.