Is there a way to efficiently convert the inspection_date field in my database from string to date for all objects, similar to the structure below? {"name": "$1 STORE", "address": "5573 ROSEMEAD BLVD", "city": "TEMPLE CITY", "zipcode": "91780", "state": "C ...
I'm currently facing an issue where I am attempting to update a user's document in the database with a value obtained from a calculator. However, despite not encountering any errors, the document does not seem to be updating and the page just con ...
I've been attempting to link my NodeJs application with the CosmosDb emulator on localhost: https://i.stack.imgur.com/VkAiC.png Within my azure resource group, I have set up a cosmodb instance of type MongoDB https://i.stack.imgur.com/v8KRx.png To ...
As I parse through a CSV file, I aim to verify if the corresponding entry exists in the database for each row. If it does exist, I want to update it; if it doesn't, I want to create a new entry. The process seems to be sluggish, averaging only around ...
My goal is to develop an Android app that can function completely offline, allowing users to add new entries, view existing ones, delete and edit them without requiring internet access. For the backend, I plan to use nodejs with express and MongoDB. While ...
I am currently working on setting up a docker application with two containers: mongo app While the mongo container is functioning properly, the app container is unable to establish a connection with mongo. Neither the node.js app nor mongostat are able ...
I have set up a basic post request in my code like this: app.post('/', (req, res) => { return res.status(200).json(req.body) }) However, when I try to make a post request using Postman, it returns an empty response {}. Below is the content ...
I am trying to store details in MongoDB and upload images to an "images" folder using Multer, but I am facing issues with retrieving the data on the server-side. const onSubmit = async (object) => { const fd = new FormData() fd.append('n ...
I've developed an express.js application that integrates with MongoDB using mongoose. Currently, I have the mongoose connection code stored in a separate file since it's used across multiple modules frequently. Below is the connector code: con ...
Having some issues with my application currently... This is the models.js file I'm working with: var mongoose = require('mongoose'); var User = new mongoose.Schema({ username: String, password: String, created_at: {type: Date, ...
Implementing DDD in a node.js application with es6 and mongoose for the data access layer. I observed that mongoose has a ".methods" property linked to the model schema. Would it be best to add business logic here or create a separate object mirroring th ...
I have successfully set up a local MongoDB connection with a React, GraphQL application. All configurations are in place and functioning properly as far as I can tell. To visually view my MongoDB databases, I have installed Compass. The content of the Ser ...
I keep encountering an issue when trying to execute user.comparePassword from exports.index.post. The issues seems to be isolated to the code provided below, which includes all relevant information. While the UserSchema.pre('save') method works without any ...
Having resolved previous issues, my focus now is on populating the user document with posts. Here is the current structure of the user document: { "posts": [], "_id": "5e75cf827ef14514f69c6714", "username": "di ...
I came across this helpful model at : 'use strict'; var mongoose = require('mongoose'); var Schema = mongoose.Schema; var TaskSchema = new Schema({ name: { type: String, required: 'Kindly enter the name of the task' }, Created_date: { ...
Why does Mongoose consistently return null instead of an error when no result is found? Person.findOne({ 'name': 'Ghost' }, function (err, person) { console.log(err); // null if (err) return handleError(err); }); I cannot find the person 'Ghost' in m ...
I'm looking for guidance on how to implement email verification during the signup process in MERN Stack. I would like to send an email containing a link that redirects users to a specific page. Below is my node.js code for sign up - can anyone advise me ...
I am working on creating a basic restful API and I'm facing challenges with updating specific fields in my mongodb using mongoose. Here is the Schema I am using: Sound = new Schema({ "title" : String, "url" : String, "time" : Numbe ...
I'm currently trying to connect my node app with my DigitalOcean DB. Despite using a npm package called tunnel-ssh, I am facing difficulties establishing the connection. The code snippet I am working with is provided below. Although the message "DB connec ...
As a newcomer to MongoDB, I am currently working on developing a function that can calculate the average marks for a student. I have formulated the following document: student = { "id": 123456, "name": "John", "surname": " ...
Hi there, I am a new web developer and currently working with Mongo/Express/Node stack. My current project involves creating an e-commerce site where the admin can add new "categories" to the database. Whenever a new category is added, I want to dynamical ...
Essentially, I am looking for a way for nodeJS to determine if the user logging in through the login page is an admin or not. If they are an admin, they should be directed to the admin page; if not, they should be sent to a different page. Currently, I ha ...
When attempting to retrieve data using findById(), I'm encountering a problem. If I provide a correct ObjectID, the data is returned successfully. However, if I use an invalid ObjectID or an empty string, it gets stuck. If findById() is called with a ...
Currently, I am working on implementing a basic login system using express sessions. However, I have encountered an issue where I receive an "Invalid status code" message when the user is not found in the database. I am aiming to set it up so that if the ...
Hello, I am delving into MEAN stack development for the first time. Can anyone guide me on how to perform a search in Mongoose populate array? The array contains a reference. Discussion Schema: const discussionSchema = new Schema({ user_id: { type: ...
I'm completely new to NodeJs, MongoDB, and web development in general. Recently, I came across a tutorial from about 2 years ago on creating a registration system. The author was able to successfully send a post request using Postman and save the data ...
Searching for users in close proximity with specific criteria, I can't seem to get the desired results when using field1=No and field2=No (which is what cat represents as field2). The query returns empty. function (currentLoc, radius, cat, db, callback) { ...
I have created a Mongoose aggregation to filter values from the database and return them sorted by frequency. The goal is to extract unique partners from multiple documents, sorting them based on how often they appear in the collection. For example: { ...
I am currently running node version 0.10.28 Whenever I try to run node-gyp install, it gets stuck and I can't proceed with anything else. I'm trying to install the mongodb driver for node.js (npm install mongodb). However, it's asking me t ...
Having successfully created API's for a standard transaction application (using mongoDB for DB), I have API's set up for users, products, and orders. While I've been able to effectively use and display the information stored about users and products, I'm f ...
I am facing an issue while attempting to store data in an array within an object in a Mongo model by utilizing the req.params method. Unfortunately, I encounter the following error: MongoError: cannot use the part (friends of friends.username) to traverse ...
I'm encountering an issue when attempting to run "mongod" in the terminal. Despite trying various troubleshooting methods such as uninstalling, reinstalling, and rebooting the machine, I am still unable to resolve the error. If anyone has any suggestions o ...
Currently working on a basic MEAN web application and just getting started with the stack. The front end is up and running smoothly, but when I try to integrate the following lines into app.js: var mongoose = require('mongoose'); require('. ...
Backend Server-Side Code The following is my server-side code. Below it, you can find the client-side code along with the error that is being displayed. I am having trouble identifying what the issue might be. app.post("/service", async (res, re ...
Although I am not a complete novice with Populate user, I seem to be facing some issues now. My current dilemma involves populating my designerId, which is of type ObjectId. Please review the code snippet from my route below: ordersAdminRouter.route('/cu ...
I'm trying to filter data by year in MongoDB based on a specific year and month. For example, if I pass in the year 2022, I only want to see data from that year. However, when I try using the $gte and $lte tags, it returns empty results. Can someone g ...
Currently, I am developing an e-commerce application using next.js with Typescript and MongoDB. To better understand my project, let's take a look at my existing file structure: https://i.stack.imgur.com/tZqVm.png The mainPage.tsx file is responsibl ...
What is the best way to conduct load testing with NodeJS and MongoDB using Jmeter? Our goal is to assess the performance of NodeJS and Mongo Db. ...
There seems to be an issue with passing the value of brandSelection in the web API controller. Here is my Angular service's $http.get() method: var _getItemByCategoryId = function (categoryId, currentPageNum, brandSelection) { var deferred = $q.defe ...
I am looking to execute a separate function, like a Service function, before Sails renders the page into HTML. Please refer to the controller code below... var MYController = { index: function(req, res, next) { req.flash("error", "Testing hello ...
It's common knowledge that using {$in: {_id: []}} in MongoDB doesn't maintain order. To address this issue, I am considering utilizing Async.js. Let's consider an example: const ids = [3,1,2]; // Initial ids retrieved from aggregation const documents = ...
Seeking guidance on fetching and summing up the values of the "caseCount" objects within a schema. Can anyone provide me with assistance in accomplishing this task? Feel free to ask for further details if needed. Thank you! This is the Schema: const Profi ...
If the command npm install mongodb is executed, the desired version of mongodb gets installed successfully: - email protected node_modules/mongodb/node_modules/bson email protected] /home/lorencm/Downloads/mongo-invoices └─┬ email protected] ├ ...
Considering creating an API using NodeJS with mongoose has crossed my mind. I understand that mongoose typically uses one connection per app. However, if we were to hypothetically have 300,000 users simultaneously joining a live room to participate in ans ...
I have created a Comment Model with specific fields including userId, contentId, repliedTo, and text. The schema for the Comment Model is defined as follows: const CommentSchema = mongoose.Schema({ userId: { type: mongoose.Schema.Types.ObjectId ...
I am currently working on implementing the node-lastfmapi track.search method into my project. I have successfully retrieved the results, but I am facing challenges in integrating them into the front end using Angular. My backend is powered by mongoDB and ...
I am experiencing issues when trying to deploy my Next.js app on Vercel with a MongoDB connection. I have added environment variables on the Vercel site where we deploy the Next.js app. Is there anything wrong in the following file? next.config.js module. ...
While feeling very tired, I attempted to uninstall my node.js due to some issues and ended up accidentally deleting two important folders, /usr/local/lib and /usr/local/include, on my Mac Mojave! After reinstalling the OS, much to my surprise, all my pers ...
[ Issue resolved... the solution turned out to be surprisingly simple... $scope.article = articleFactory.getArticles().get({id:parseInt($stateParams.id,10)}) .$promise.then( should have been: $scope.article = articleFactory.getArticles().get ...
Hello everyone, I currently have an array of objects containing some populated fields. Below is the product schema: import mongoose, { Schema } from 'mongoose'; const productSchema = new mongoose.Schema( { name: String, description: S ...
I am facing a challenge where I need to assign unique IDs to each object within an array. Here is the structure of my schema: { _id: something, property:value, animals: [ { dogs: [ { name: 'Dog1' }, { name: ...
I am currently working on a project to develop a basic webpage that requires the user to input a specific time and then click on submit. Once submitted, I want the relevant data linked to that input to be displayed on the webpage. Upon clicking the submit ...
After going through numerous tutorials, I find myself stuck at a point where I am struggling to render all the data written by my express-app into MongoDB in embedded JavaScript. My goal is to display this data in a simple table that always shows the updat ...
Looking for a way to merge two collections into one while ensuring that duplicates aren't included in the final result. Any suggestions on how to achieve this? I've heard about aggregation and map reduce methods, but I'm not sure which one i ...
mongo.connect('mongodb://localhost',{useUnifiedTopology: true}).then((client) => { var db = client.db('complainbox'); db.collection('admin').findOne({"Email":req.body.Email},(err,result)=>{ assert. ...
I have been developing an app that involves using databases to add items for users based on their user ID, which is their username. However, whenever I attempt to add an item, I encounter an error that I can't seem to troubleshoot. The error message reads ...
After saving an object to the database using the following code: var newObject = new PObject({ value : 'before', id : 123456 }); newObject.save(function(err) { if (err) console.lo ...
There seems to be a problem with the [email protected] npm dependency. I am attempting to incorporate mongodb into my Vue.js + Vite + Typescript application, but it crashes and fails to load due to an error originating from mongodb. It appears that th ...
I am looking to insert a large amount of data into mongoDB using the following code snippet: const data = [{user : "1",password: "1"}, {user : "2",password: "2"}, {user : "3",password: "3"}, // up ...
I am currently developing a small application that allows users to sign up for karaoke music. To fetch information from a mongoDB, I am using SWR, but facing performance issues. In an attempt to improve the user interface, I am trying to implement optimist ...
As someone who is fairly new to these technologies, I'm unsure if I am doing this correctly. I am attempting to display the name of the category in the table instead of the id (which is from the ObjectId schema field) for all the Category documents r ...
Seeking assistance in creating a voting system that involves an array of objects containing user IDs and their corresponding vote values. If a user has previously voted but wants to change their rating, the goal is to update the rate value in the array fo ...
I have been developing a CMS on nodejs which can be found at this link. I have incorporated some event hooks, such as: mpObj.emit('MP:FOOTER', '<center>MPTEST Plugin loaded successfully.</center>'); Whenever I handle this ...
I have implemented the MongoDB util function provided in Next.js's example template and encountered an issue with its usage: import { MongoClient } from 'mongodb'; const uri = process.env.MONGODB_URI; const options = {}; let client; let clientPromise; i ...
Currently, I am working on developing a MERN app on my local machine. The front end portion of the application can be accessed at localhost:3000 While the back end is running on localhost:3003 In the front end code, there is a request configured as: ax ...
The primary function of the application interface is to provide variables that have been initially posted by the client, as well as any subsequent database calculations carried out in real time by a specialized engine. Is it possible to integrate this eng ...
I'm struggling with English and need some help. Here are two schemas and a query I've been working on: /models/user_schema const mongoose = require('mongoose'); const bcrypt = require('bcrypt'); const { Schema } = mongoose; const userSchema = new Schema ...
After successfully implementing a schema/model for a recursive tree structure in Mongoose, I have decided to enhance my current setup by integrating two specific packages designed to streamline the process: Utilizing mongoose-mpath will allow me to man ...
I am currently facing a challenge with updating MongoDB using Mongoose. Although there are no error messages, the update process is not taking place even after trying various solutions. exports.update_a_keyValue = function(req, res) { console.log("tem ...
Recently, I encountered an issue while attempting to install packages using npm. Unfortunately, the process seems to be stuck and the packages are not getting downloaded properly. Below is a snippet of the installation process with the --verbose flag enabl ...
I am looking to add another array data to an existing record in MongoDB. For example: Current record in the database: { "_id" : 1, "name" : "main", "sample_details" : [ { "detail_no" : 1, "email" : "<a hre ...
After performing a forEach inside an asynchronous method, I am trying to return an array of names. The issue is that despite the forEach working correctly, the array always ends up empty. On the website side, here is my request: function retrieveCharity( ...
After exploring numerous similar questions, I have yet to find a solution to my specific issue. In my database, I have a PHP nested array that needs to be printed in its entirety. The current output only displays the values of the topmost array ('name' wit ...
Recently, I encountered an issue while trying to establish a connection to my MongoDB database. Despite following the instructions in my learning modules, I was unable to make it work using the provided code snippet: const mongoose = require('mongoose'); ...
After coming across numerous questions on stack overflow related to this error without finding a solution that works for me, I've decided to ask my own question. (probably due to my limited understanding of javascript/node/mongoose) The modules I am using ...