I have a simple Express/Pug app that is supposed to allow me to search users in a database by “email” and by “key.” In this schema, a key is simply a string that each user is assigned. My user model and index model files look like this: models/index.js: models/users.model.js: My controller file looks like this: controllers/users.controllers.js: My users route looks
Tag: express
the id of cart shows null in controller but i m sure i m sending it NODE JS
I m sending the id of the product from this view (I m using express and mongoose db) I m sure it is not null here then I have this middleware to receive it and here is the function post Cart When I first receive it in the postcard function I made a log and it gives me the log
MongoDB FIND method does not work in code
so when I try to find items in a collection through the console using the method db.DB_NAME.find({ x: y }, it works just fine. However, when trying to do the same in the code, it does not work. Perhaps it is worthy mentioning that the method findOne works great within the code. Consulting through the console Code: What I get
How to create an array in the GraphQL’s argumment as GraphQL Code First Approach
In GraphQL Code First Approach I am trying to pass the same argumment for createUser in createManyUser but I want to pass it as an array to create many users at once. I searched a lot but couldn’t find it in GraphQL Code First Approach. The Code Answer You can’t just put the args options in an array, to tell
How to pass an array from a form into a URL with JavaScript?
I have a form which uses a get method. There is a select element in the form that allows the user to select multiple options. This gets passed to the URL when the user clicks submit. However, it does not get neatly presented in the URL at all. Is there a a way to pass the array in a neat
Unable to load CSS file within nodeJS app
I have an app that I followed from a tutorial for the backend in nodeJS and Express. My connection to MongoDB via Mongoose is working. However, I’ve been trying to add a front-end- at the moment- just a simple html/ejs/css form. My endpoints are loading in localhost but only the html/ejs is rendering. My css file shows as plain code
JavaScript, how to run a piece of code only once?
I am saving my .env content dynamically from the AWS secrets manager, but I want to save all values just once the server starts. What should be the approach? I am using TypeScript: Answer You could use a boolean to remember whether the code has been executed or not. Something like this:
“TypeError: Cannot read properties of undefined (reading ‘hasOwnProperty’)” error
EDIT: PROBLEM SOLVED. I’m trying to make an update profile page for an Express app with Mongoose, and I got the error “TypeError: Cannot read properties of undefined (reading ‘hasOwnProperty’)”. I am confused how to fix it. Here is my code, thanks (error shown) [1]: https://i.stack.imgur.com/xss8j.png Answer So… idk why this works but I forgot to make the profile picture
Tailwindcss not rendering in ExpressJS/React app
I am trying to add TailwindCSS to my existing Express JS + React application. I have tried many different tutorials, such as this one https://tailwindcss.com/docs/installation for regular JS, and this one made specifically for Create-React-App https://tailwindcss.com/docs/guides/create-react-app . I later tried this tutorial for express js https://daily.dev/blog/how-to-use-tailwindcss-with-node-js-express-and-pug My project was initially made with Create-React-App, but I later changed everything to run
Is new keyword is necessary with ObjectID in MongoDB Query
I was working on a Typescript web project that used MongoDB and ExpressJS. I used a MongoDB query to find and delete a document from MongoDB using the HTTP DELETE method. During the MongoDB query, I got mixed up with a term named new and ObjectID. Here are the code snippets: Both are working fine as I expected. But I