Skip to content

Commit

Permalink
fix user model
Browse files Browse the repository at this point in the history
  • Loading branch information
imranpollob committed Jul 8, 2019
1 parent 73a927c commit 95fd8de
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 82 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ app.use(authRoutes);

app.use(errorController.get404);

mongoose.connect('', { useNewUrlParser: true })
mongoose.connect(MONGODB_URI, { useNewUrlParser: true })
.then(result => app.listen(3005))
.catch(err => console.log(err));
72 changes: 0 additions & 72 deletions models/cart.js

This file was deleted.

13 changes: 4 additions & 9 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const mongoose = require('mongoose');
const { Schema } = mongoose;

const userSchema = new Schema({
name: {
email: {
type: String,
required: true
},
email: {
password: {
type: String,
required: true
},
Expand All @@ -19,10 +19,7 @@ const userSchema = new Schema({
ref: 'Product',
required: true
},
quantity: {
type: Number,
required: true
}
quantity: { type: Number, required: true }
}
]
}
Expand Down Expand Up @@ -52,9 +49,7 @@ userSchema.methods.addToCart = function (product) {
};

userSchema.methods.removeFromCart = function (productId) {
const updatedCartItems = this.cart.items.filter(
item => item.productId.toString() !== productId.toString()
);
const updatedCartItems = this.cart.items.filter(item => item.productId.toString() !== productId.toString());
this.cart.items = updatedCartItems;
return this.save();
};
Expand Down

0 comments on commit 95fd8de

Please sign in to comment.