Mongodb – Host server on Heroku
I have been trying to deploy a server for my first MERN app for the past week but I can't seem to get it work. It works perfectly when I host it locally but I can't seem to get the…
I have been trying to deploy a server for my first MERN app for the past week but I can't seem to get it work. It works perfectly when I host it locally but I can't seem to get the…
I'm in a NodeJS server using ExpressJS to handle my /register route. One step in my registration process is to ensure that the user's username and email are both unique, if so, they can register and add their account to…
My Collection.save() function is working fine and identifying duplicate key values. But, when duplicate values occur , I am not able to get the entire error message as response. My User.save function const user = new User({ first_name, last_name, email,…
I am creating a query to extract description of customers in mongodb. Unfortunately, the description is in HTML Format. Is there a way to replace all HTML tags and make it as " ". Either replace it with " "…
the below is my controller function exports.validateUsername = async (uName) => { console.log("inside validate username"); await User.findOne({ username: "sab2" }).then(function (err, user) { if (err) { console.log("inside err"); console.log("error"); console.log(err); return true; } else { console.log("inside user found"); console.log("user"); console.log(user);…
I've been trying to connect my frontend and backend for a webapp and I have an issue where, when a user creates an account, multiple objects for that user get created in the database. I used console.log and found that…
Im trying to call an API to fetch the data and move it to mongodb from my react application to the node js server but im keep getting that error along with another error in the console. I tried to…
I have user schema and invitation schema. When user search for users I want to return array with object that have property invited. const InvitationSchema = new Schema<IInvitation>( { sender: { type: Schema.Types.ObjectId, ref: 'user' }, receiver: { type: Schema.Types.ObjectId,…
I am trying to follow the onlinecodeacademy online course for free to learn MERN. I am having trouble both using npx and installing it. When I try to install npx I receive the following errors: [noah@Qyain restaurant-reviews]$ npm install npx…
I have two mongodb aggregate query as shown below. The below query gives me the count of total failed and the sectionType db.Departments.aggregate([ { $match: {$and: [{"subject.failed": {$eq: 'true'}}, {"section": {$eq: 'A'}}]} }, { $group: { _id: {"sectionType": "$sectionType"}, "COUNT(*)":…