I am facing an issue while trying to upload data to a MongoDB using React, Node.js, and Express. When I attach an image to the code, it shows me an error, but without the image, the data gets stored in the database. Here is my React code snippet: import ...
I am facing an issue with uploading a form that includes an image to my mongodb database. While all the data is being stored correctly, the images are not visible in the database. I suspect this might be related to the error message 'typeError cannot ...
Currently, I am managing an Express application that interacts with a MongoDB through Mongoose. The main functionality involves a basic content management system that allows for updating values on specific pages. Strangely, when changes are made on my stag ...
As a complete beginner, I am currently following a tutorial to grasp the fundamentals of the MEAN stack. My current challenge involves retrieving documents from my database and displaying them on a webpage, but all I get is an empty array. To provide some ...
I have a variety of collections stored on a remote MongoDB server. My objective is to retrieve a specific collection based on the city name. I am currently using POSTMAN to mimic a GET request, but it seems that a different GET method is being triggered: { ...
I have a database collection with three fields: name (String), email (String), and appointments (Object) When the user queries the collection based on their email, it is done inside a router.get method router.get('/appointments', ensureAuthenticated, fun ...
I have a vision for an app that allows users to tag their content using Node and MongoDB. Progressing, I successfully managed to store the tags in the database as an array: "tags": [ "laughing", "smile" ] However, I encountered an issue while tr ...
I am dealing with a straightforward document(row) structure within a collection(table) called user_records. Here is an example: [ { _id: new ObjectId("652edd74bdb84c9944d280d6"), customer_id: 1001, first_name: 'Test', ...
My goal is to query the database for documents and if a certain field is not set, I want to replace it with a custom value. Let's say I have a collection of songs in my database where some have 'pathToCover' set and some don't. In those cases where it's no ...
I have a task to fetch details from the database using an ID and display them in a table. However, initially, I just want to display them on the browser without any formatting. When I try to do this, I encounter an error message saying 'values.map is not a ...
After completing the MongoDB tutorial for nodejs on their website, I am in the process of creating a simple test case to send query results to a Google Chart using AJAX. Below is the nodejs code snippet used to form the query: CODE: var MongoClient = re ...
While performing a put request on my database, everything seems to be working fine as expected. However, there is this persistent message appearing in the console that I suspect might impede my progress. Cannot set headers after they are sent to the client ...
Every time I attempt to create a new project using Angular CLI by typing: ng n app I encounter the following error message: C:UsersVenkateshwarn MAppDataRoaming pm ode_modules@angularcliin g:26 ); ^ Syntax ...
Currently, my validation process involves using the pre('save') method: UserSchema.pre('save', true, function(next, done) { var self = this //in case inside a callback var msg = helper.validation.user.username(self.username) if (msg) { ...
I am in the process of building a web platform with Spring and Angular. One important element I want to include is Power Bi integration, allowing me to generate datasets and reports using Spring and display charts in Angular. Are there any resources or t ...
I am facing a roadblock at the moment. I have a form that is used for writing blog posts and I was previously using multer to upload images to mongodb as a datastream. However, due to scalability issues, I decided to switch to uploading images to S3 but I' ...
Currently, I am utilizing the following code snippet to establish a connection with MongoDB: MongoClient.connect( process.env.MONGO_HOST, { useUnifiedTopology: true }, function (err, client) { _db = client.db(process.env.DB_NAME); ...
In this scenario, we have two models - ProductModel and CategoryModel. The goal here is to establish a connection between creating a product (ProductModel) and assigning it to a category. The issue arises when the category field is not getting filled in t ...
My attempt to send a GET request to the Mongo works fine, but I'm having trouble getting the PUT request to work. My suspicion is that there might be an issue with the path from the controller to the router. I've already tried using both update() and findB ...
Within my Mongoose schema, there is a specific field named id which holds a unique identifier for each document. This operates using the same system as the standard _id field as shown below: var JobSchema = new mongoose.Schema({ id: { type:String, requi ...
I've encountered a perplexing anomaly with mongoose - whenever I attempt to store a large number (specifically 76561198063200687), both mongoose and mongodb mishandle the integer. For instance, when executing SomeModel.findOneAndUpdate({name: "Pietrov"}, ...
Encountering a challenge in my initial node app development, where the callback function is triggered before the database write operation is fully completed. The issue arises when an authenticated user visits site.com/model URL. The system checks the data ...
I am in the process of creating a poll application, and one of the routes I have set up is a GET request to retrieve all the polls. My goal is simply to pass the polls data to my dashboard view. In cases where there are no polls available, I also want to ...
I'm a bit confused here, but let me try to explain. When creating a new mongoose.model, I do it like this: let MyModel = moongoose.model<IMyModel>("myModel", MyModelSchema); What exactly is the difference between MyModel and let newModel = new MyM ...
I am searching for data by its ID and checking to see if within that ID there are no arrays containing object IDs that need to match as well. Here is how I attempted it const exists = await Partners.find({ '_id': req.params.id, partnerLikeuser: { $elemMat ...
When running npm i, I encountered an error. The error message is as follows: "../@types/mongoose/index.d.ts:191:17 - error TS2694: Namespace '"/Users/test-service/node_modules/@types/mongodb/index"' has no exported member 'OptionalId' ? mongodb.OptionalI ...
In my current Mongoose setup, I am facing a scenario where I need to search for a customer in the database. If the customer exists, I should return their customerId. However, if the customer does not exist, I want to create them and then return the custome ...
ReviewSchema with Mongoose: import mongoose from "mongoose"; const ReviewSchema = new mongoose.Schema({ likes: { type: Number, required: true, default: 0, }, reactedBy: [ { required: true, ...
I've encountered an issue with posting AngularJS to Express 4.0 and could use some help! After taking a MEAN stack course on Pluralsight, I downloaded the source code from my instructor's GitHub repository (Github - Course Source Code). You can ...
Currently, I am working on implementing an asynchronous method that involves making a POST call to a specific API to fetch data and then storing the result in the user's session. Although the task itself seems straightforward, it becomes challenging when a ...
My scenario involves a collection structured as follows: A document contains an array of suggestions, with each suggestion potentially containing an array of emotes. Importantly, a user is restricted to emoting once per suggestion. It's worth noting that a ...
I have successfully retrieved data from MongoDB and displayed it in Bootstrap 5 cards. However, I am facing an issue where all the cards are appearing in a single row if there are multiple entries in the database. What I want to achieve is to utilize the ...
Currently, my setup includes env with python311, pydantic, fastapi, and mongod. return membercollection(members=await c_members.find(queryparam).to_list(1000)) This code snippet retrieves the following information: members=[membermodel(id='65b3908a77efb45 ...
I am currently using Mongoose to retrieve data based on a specific date from my database. Specifically, I am trying to fetch any account that has not been accessed for more than an hour. However, when executing the query below, I am not receiving any resu ...
Background: In my quest to optimize the speed of my Node.js API running on Express and Mongoose in the Amazon Cloud, I encountered a challenge. One specific API call (/stats) takes approximately 20 seconds to execute due to multiple mongo queries pulling d ...
When working with mongoose, I have encountered an issue where combining data from multiple finds only displays the id instead of the entire object. Interestingly, when I use console.log() on the object directly, it shows all the contents. Below are snippe ...
Below are the schemas for two different collections. var activitySchema = new Schema({ activity_id: {type: String, index: {unique: true}, required: true}, begin_date : String, ... }) var registrationSchema = new Schema({ activit ...
Having trouble merging a client and an account collection. When I use res.send(client), only the account id's are returned. Unsure how to include account information in clients. Have seen one to many solutions, but struggling with this two-way relationshi ...
Here is the JSON structure provided: [{ "_id" : ObjectId("626204345ae3d8ec53ef41ee"), "categoryName" : "Test Cate", "__v" : 0, "createdAt" : ISODate("2022-04-22T01:26:11.627Z"), "items" : [ { ...
Currently, I am in the process of designing the database for my MERN application (which employs Next.js in addition to React.js). The main purpose of my app is to serve as an LMS (Learning Management System) where educators can post assignments, tests, r ...
I currently have a get method in my Express app that renders data from a MongoDB collection called "Members" on the URL "/agileApp". This is working fine, but I now also want to render another collection called "Tasks" on the same URL. Is it possible to ...
Currently, I am working on writing data to a JSON file and retrieving it back to an HTML page for display. Now, I want to achieve the same functionality with a MongoDB database. I have made some attempts, but unfortunately, it is not functioning as expecte ...
UPDATE: After attempting different ports, terminating tasks on ports, and trying again, I am still unable to connect. Today, I embarked on a tutorial for the MERN stack but unfortunately, I am unable to establish a connection to the server. Upon using npm ...
I'm currently working on a genealogy application using node js express and ejs but I'm facing an issue with displaying the database in order (starting from parent). This is the code snippet for retrieving my data and what I see when I log the ou ...
Currently, I am involved in the development of a MEAN stack application for my school project. The main objective is to allow users to view and submit highscores for Galaga and Dig Dug games to a MongoDB database. An issue that I am facing is: POST http ...
I want to calculate the total sum of "paid_amount" based on "user_id", "real_currency_spend", and "paid_currency". The objective is to obtain totals per user per currency type, ensuring Yen "paid_amount" are not mixed with USD, GBP, etc. The current code ...
I'm currently in the process of working with Express and MongoDB, where I have data items structured like the following: { "_id": { "$oid": "63107332e573393f34cb4fc6" }, "title": "Eiffel tower", ...
I am working on creating a GET API route to retrieve all tasks assigned to a specific user. However, when I test the call (http://localhost:4000/api/taskuser/getalltasks?userId=5bfe4af425ddde2b04eb19c6), I am not getting any errors but still receiving all ...
Encountering an issue with my graphql query not returning anything when sending the _id as a string. Interestingly, querying the DB using any other stored key (like name: "Account 1") works perfectly and returns the object. I've defined my Account sch ...
While attempting to integrate an array of JSON data from a different server into a MongoDB collection, I encountered the following error message: "Cannot create property '_id' on string". Even though I am passing in an array, it seems to be causing issue ...
While there are many resources available on saving binary files using the Mongoose Buffer SchemaType, most of them focus on image files. I have encountered difficulties in making it work with a WAV audio file. Currently, I am utilizing Recorder.js to stor ...
Currently, I am seeking a reliable example of developing a PHP class that can manage connections to multiple MongoDB databases. In my current project, I need to interact with at least five distinct databases. It would be quite resource-intensive if I had t ...
I am looking to implement elasticsearch using Node.js, MongoDB and Elasticsearch technologies. Can anyone provide me with any sample code or tutorials for this project? I would appreciate any guidance on where to find the necessary tutorial or examples. ...
Apologies for any spelling errors, I am a French student. Currently, I am working on a test project using NodeJs, Express, and MongoDB. I am trying to display my MongoDB data on my index.ejs page but struggling to make the connection between my database ...
I've encountered some challenges while developing a login system and I'm struggling to find a solution. I've experimented with different options involving find() and findOne(), but none seem to work for my specific case. Below is the initial ...
My technology stack includes Node.js and MongoDB with a rest api. The input data I'm dealing with looks like this: var doc={"name":"ABX", duedate : new Date() } Before sending it to the server, I stringify the data: /rest/update?doc=JSON.string ...
Struggling with setting up my first basic CRUD functionality in Express JS and I can't seem to track down this frustrating bug. Every time I attempt to update a field, instead of displaying the new data, the JSON from that field is shown on the view. ...
My mongodb collection is named 'people' and the schema looks like this: people: { name: String, friends: [{firstName: String, lastName: String}] } I have an express application that connects to this database and successfully cre ...
When sending data from NodeJS Backend to the client, I utilize the following code: res.end(filex.replace("<userdata>", JSON.stringify({name:user.name, uid:user._id, profile:user.profile}) )) //No errors occur here and the object is successfully stri ...
One of my current tasks involves creating an API endpoint with specific functionality. The goal is to input an Object ID into the path, locate the record associated with that ID, access a particular field within this object which contains another ObjectID ...
I've been working on a React and NextJS App for about a month now, utilizing MongoDB as my database through MongoDB Atlas. I'm currently using the free version of MongoDB Atlas. For the backend, I rely on NextJS's api folder. Everything wa ...
Recently, I've started learning about MongoDB. I'm attempting to run mongod in the directory C:\Program Files\MongoDB\Server\3.2\bin but unfortunately, I keep encountering an error message. For reference, here's a s ...
When visitors land on my web app's homepage, a GET request is triggered to fetch a current list of Stadiums stored in the database through my API. However, the Stadium objects retrieved are packed with unnecessary data, particularly extensive arrays of pho ...
I am currently working on the Populate method in Mongoose. Here is my query: await User.findOne({_id: req.params.userId}).populate({ path: 'review' }).then(result=>{ console.log("here" + result) if(result && r ...
I need to perform an insert/update operation (upsert) on a document. In the snippet below, there is a syntactical error, but this is what I am attempting to achieve: $inc: { {type=="profileCompletion"?"profileCompletion":"matchNotification"}: 1}, If the ...
I am facing a particular issue. I have comments in my database that can be soft-deleted using a flag is_deleted. When this flag is set to true, it means the comment has been deleted. The comments are not stored as an independent model; instead, they are n ...
Currently, I am working with meanjs and I have a requirement to store user data in a one-to-many relationship. Even though my scenario is similar to the articles example, articles will only be accessed through the user. I envision the route to look somethi ...
My MongoDB collection looks something like this: _id: ObjectId("5cb089e459552d8b8cc6a9e4") username: "admin" password: "12345" gender: "male" interestedIn: "female" movie: Array 0: Object id: "Avatar" title: "Avatar" poster: "~" 1: Object ...
Running a web server on node, here is the code: var restify = require('restify'); var server = restify.createServer(); var quotes = [ { author : 'Audrey Hepburn', text : "Nothing is impossible, the word itself says 'I'm p ...
How can a MongoStore be initialized to connect to a database and authenticate with the "admin" one? Can it be achieved similar to this using mongoose: var db = mongoose.createConnection('mongodb://myname:mypwd@localhost:27017/mydb', { auth: { authdb:"adm ...
I am currently working on a route in Express and Mongoose that updates 2 collections within one route. The updates are successful and can be seen in MongoDb, but after the request is made, the server crashes with the error code: 'ERR_HTTP_HEADERS_SENT ...
As a newcomer to Node Express Mongo, I decided to venture into creating my own website after following tutorials. The page I'm working on is a login page. While other people's code has worked for me, my attempt didn't go as planned. Even con ...
After reading and attempting to implement the solutions provided by others, I am still struggling to understand why it's not working for me. This is my first project involving backend development. While progressing through a course, I decided to work on so ...
Trying to include an array in the request body for a POST call to MongoDB, aiming to insert a new document upon success. See my current code snippet below: app.post(`/api/add`, async (req, res) => { collection.create({ 'id': req.body.id, ...
I'm encountering an issue with my code. It works fine for uploading images, but when I try to upload videos or files larger than 16mb, it fails. I am a beginner and seeking help on what to do next. const Freecoursevideo = require("../models/freecour ...