I am struggling to reuse some code in two separate NodeJS controllers, and it seems like I'm having trouble understanding how the function calls work. The data is coming from a MongoDB using Mongoose. When I call the findMyBoatPictures code on its own, ev ...
As a newcomer to React.js, I recently came across an article detailing how to perform CRUD operations with React Express and MongoDB. However, after implementing the code, I encountered an issue when trying to add a user. Upon clicking the 'Save' button, ...
In my React application, I have created a form to input certain values which will then be stored in a MongoDB database named tasks. The code block I have implemented is as follows: import React, { useState, useEffect } from 'react'; import &apos ...
Within my dataset, I've got a string comprising JSON entries linked together similar to the following scenario. val docs = """ {"name": "Bilbo Baggins", "age": 50}{"name": "Gandalf", "age": 1000}{"name": "Thorin", "age": 195}{"name": "Balin", "age": 178 ...
My goal is to store an uploaded file, like an image, in a mongodb database. However, I keep encountering a Type Error when trying to set up the gridfs-stream. Below is my code snippet: var mongo = require('mongodb'); router.post('/createpost', cpUpload, ...
In my setup, I have two collections: one is called subcategories and the other is called categories. The categories collection includes a field known as subcategories which is an array containing the ids of the subcategories from the subcategories collecti ...
Utilizing fetch() to make a call to a URL looks like this: const context = useContext(AuthContext); const navigate = useNavigate(); const handleSubmit = (event) => { event.preventDefault(); const dat ...
I am currently working on implementing a user search feature using Angular to query users from a MongoDB collection. The function on the server side is already operational and functioning correctly with Postman. However, I encountered an error on the clien ...
Software Version: "@mui/x-data-grid": "^6.2.1" I have a script that generates columns for the DataGrid as shown below (only including relevant code) if (prop === "date" || prop === "dateModified" || prop === "n ...
I am looking to retrieve comprehensive information about a collection known as "commercant", which includes another collection called "personne" in the front end using ReactJs. Although Postman returns all data, the front end is struggling to interpret the ...
I've been diving into a YouTube tutorial on building a blog with node, MongoDB, and express. There are certain concepts that I'm finding tricky to grasp. <!--Creating the Article Cards--> <% article.forEach(article =>{ %& ...
try { if (!conn) { console.log("Attempting to Connect to Atlas"); conn = await MongoClient.connect(process.env.MONGO_URL, { useNewUrlParser: true, useUnifiedTopology: true, }); console.log("Success ...
As someone who is new to backend development, I am looking for a way to display a list of users from my API and check if they are currently logged in. I have successfully implemented basic authentication using passport and json web token. However, I do not ...
I am looking to implement a hidden notes functionality in my web application. When the "hide note" button is clicked, I want the note to be removed from its current location and added to a hidden notes section. Users should then have the ability to view an ...
I'm having trouble figuring out what's going on. Node v16.4.2, NPM v7.18.1 const mongoose = require("mongoose"); // const dotenv = require('dotenv') require('dotenv').config({path:'variables.env'}); mongoose.connect(process.env.MONGODB_URL, { us ...
I have a users.server.model file var mongoose = require('mongoose'), Schema = mongoose.Schema; var UserSchema = new Schema({ firstName: String, lastName: String, email: String, username: String, password: String }); mongoose. ...
When a user logs in on the frontend, this function is used to manage their session. The userData state's values are reset to undefined if the user navigates to a different page on the site. An API link "http://localhost:5000/users/isTokenValid" is cal ...
I have a strong aversion to JavaScript. I find it to be quite messy and disorganized as a language. However, I recognize that my lack of proficiency in coding with it may contribute to this perception. These past few days have been incredibly frustrating ...
I am in the process of developing a more advanced hello world application using express and mongoose. Let's assume I have the following Schemas: const pollOptionsSchema = new Schema({ name: String, votes: { type: Number, default: 0 } }); co ...
This is the MongoDB query I am working with: db.getCollection('fe_report').aggregate([{ $match: { date: { $gte: ISODate("2017-07-01T00:00:00.000Z"), $lte: ISODate("2017-07-19T00:00:00.000Z")} } }, { $group: ...
Currently, I am in the process of implementing MongoDB save functionality by submitting a form. My goal is to showcase the results obtained from the server without having to refresh the page. While I can accomplish this using $.(ajax), it presents a limita ...
Struggling to locate the solution. I have a question that may result in multiple answers, and I am looking to retrieve the most recent one. How can this be achieved? db.users.find({username: "bob", sort: {createdAt: -1}}).first() Any suggestions on how t ...
In order to create a realtime and fast trending page for newsletters, we are utilizing our extensive database. The aim is to showcase the most popular newsletters from various time frames such as the past 2 hours, 4 hours, 24 hours, past week, and month. ...
Creating a function for users to like posts has been my recent project. Each post is stored as an object in my MongoDB collection with a specific schema. { title: String, text: String } On the other hand, users have their own unique schema as well. ...
It seems like there is a simple issue causing the contact.fullName value not to update, even though contact.middleName updates correctly. The hook is triggering and the changes are showing up in the console logs, but not in the database. The fullName fiel ...
My MongoDB Locations collection contains two documents, each with its own array of confirmed bookings represented as objects with unique Ids. How can I update the object with _id: c1? Is there a way to achieve this in one query? [{ _id :63233022222222, ...
I'm looking to build my database using an external API. To begin, I've created a function called loadData(req, res){} in my DBController that retrieves data from the API in JSON format. Now, I want to save this imported JSON data into my mongoDB ...
I am working with MongoDB collections and need to showcase them on my website, creating a dynamic page that updates automatically. Specifically, I am dealing with team members' information in the database. Here is an example of how my collections look in ...
I'm curious about how to utilize an 'any json object' as a property in an entity. For instance: @MongoEntity public class ImportEvent extends PanacheMongoEntity { public String description; public JsonObject customEvent; } What t ...
Currently, I am working on implementing a deleteImage function in my front end to interact with the backend through API routes. Below is the function I have for uploading images: const uploadImages = async (ev) => { const files = ev.target?.files; ...
When it comes to connecting with mongodb, my approach looks like this: routes.js: "use strict" const Router = require("koa-router") const bind = require("koa-clean") const FsFilesController = require ("./controllers/ ...
I am faced with the challenge of handling multiple user requests simultaneously in my express server and storing their data in a MongoDB. While I have all the necessary code prepared, I am struggling to devise a method for assigning a unique identifier to ...
I have a field within my collection that looks like this: uniqueId: 123 inTarefa: true exclude: "ab,cd," orderId: 987 I am attempting to update all of the values using a "FindOneAndUpdate" query like so: collection.findOneAndUpdate({ 'uniqu ...
Can anyone guide me on how to check if a username exists in MongoDB using promises? I'm new to Node.js and would appreciate help in understanding the process. Thanks in advance. var errorsArr = []; var promise = checkUsername(); promise.then(function ...
I'm in the process of developing an automated task manager that assigns tasks to users based on their role. Currently, I'm randomly selecting a user with the same role as the task from the list of users and assigning the task to them using math.random(). ...
If a categoryId is provided, the route will return the category corresponding to that ID. If no categoryId is passed, the goal is for the route to return all categories... I attempted using $or but it consistently returns all categories regardless of wheth ...
My goal is to develop a custom concert seat booking system using HTML, CSS, and JavaScript. For example, if the concert venue has 10 rows with 20 seats in each row, I could organize them like this: const rows = [ { name: 'A', seats: [1, 2, 3, 4] }, { ...
Can someone assist me with updating a record in the database through the front-end table display? Here is a screenshot for reference: https://i.stack.imgur.com/CPLN6.png I need the entire record to be updated in the backend once I click the save button on ...
Is it more efficient to establish a connection to MongoDB using the Node.js cluster library in the master thread or in each child thread? Can multiple threads share the same connection? Considering performance, would it be better to use a single shared c ...
This pertains to a previous inquiry I made concerning my project. The scenario is as follows: I have developed a NextJS application that utilizes NextAuth with OneLogin for authentication and stores session data in Mongo Atlas. The app is hosted on Vercel. ...
Currently, I am diving into the realm of web development with MongoDB, express, react, node and GraphQL. While researching extensively, there is one concept that I'm struggling to fully grasp. The application I am working on is essentially a recipe app whe ...
I am facing an issue with managing data in my raspberry-pi sqlite3 database. I have a script set up to send this data to a MongoDB server, and once the data is sent, I want to delete the corresponding row from SQLite. However, I am encountering difficultie ...
Currently, I am in the process of developing an application using MEANJS. The mongoose schema I have set up looks like this: var UserdetailSchema = new Schema({ fullName: { type: String, trim: true }, userName: { type: ...
Currently, I am attempting to execute a query in my backend Node.js API using the mongodb-nodejs native driver where I am trying to perform an 'upsert' operation on a document using 'findOneAndUpdate'. However, the issue I am encounteri ...
After updating my server with nodemon, I encountered the following error: C:\Users\mikae\Desktop\Project\node-express-swig-mongo\node_modules\mongoose\lib\index.js:523 throw new mongoose.Error.MissingSchem ...
When pushing sub documents into an array, the structure of the subdocs typically looks like this: { id:"someId", date:Date } The goal is to only add a new subdoc if there isn't already another subdoc with a matching id. The $addToSet modifier in ...
After setting up a NodeJS server and connecting it to a MySQL database with around 5000 users, I needed to read the data from MySQL and update a MongoDB database. I managed to write code for this process. https://gist.github.com/chanakaDe/aa9d6a511070c3c78 ...
I'm looking to enhance the security of my database by allowing access requests only from the app server (which runs on backend using node.js and express.js). However, when I whitelist the IP address of the app server (Azure App Service Linux), the co ...
After completing several tutorials on nodejs, mongodb, and express, I have gained a solid understanding of the basics such as: The main controller file being app.js. Third party modules stored in their designated node_modules directory. Template files pl ...
Having trouble calling a function from another file in my JS code. I am unable to call a function from another js file. I suspect there is an issue with linking the two files. Code snippet from my first JS file const { response } = require('expre ...
Can someone please provide guidance on how to easily update the mongodb nodejs driver to the latest version? I have attempted using only npm install mongodb, but it does not seem to upgrade to the most recent driver version. I am currently working in the ...
I've been trying to update my User objects by adding a post to the array I created for them. Despite several attempts, nothing seems to be working and the user object remains unchanged. MongoDB is new to me, but I'm really enjoying using it and l ...
I'm struggling to figure out how to write a specific field from my mongodb database to a json file using node js. Can anyone provide guidance or resources? I haven't had much luck finding helpful information so far. ...
I've been searching for a method to perform various operations on a mongo database, depending on the route connected by a user on my website. For instance, performing an HTML POST request to www.mysite.com/data would add information to a mongoDB, while an ...
I have a database of documents called ChatRooms stored in MongoDB with the following structure: { _id: ObjectId('4654'), messages: [ { user: ObjectId('1234'), sentAt: ISODate('2022-03-01T00:00:00.000Z') ...
I am facing an issue with storing a product detail on the mongoDB database. When I try to save it, mongoDB stores a property imageSrc as an object instead of a string. Here is my database This is my angular service And this is my express server request ...
I need to create an array_C that includes only the elements from array_A that are not present in array_B. My approach involves using $match in aggregate to specify array_B. For instance: array_A = [1, 2, 3] array_B = [2, 4, 6, 8, 10] array_C = [1, 3] I a ...
While deploying my app on Heroku, I am facing an issue. My app uses Express and Mongodb. Even though the repository works fine during local development, when deployed on Heroku, there is an error in the logs related to the Mongodb module itself. How can I ...
I am facing an issue while using mongoose in Nest.js The error message I received is as follows: Nest can't resolve dependencies of the movieModel (?). Please ensure that the argument DatabaseConnection at index [0] is available in the MongooseModule con ...
This is the schema definition for a location: const mongoose = require('mongoose'); const Schema = mongoose.Schema; let locationSchema = new Schema({ 'locationTitle': String, 'googlePlaceId': { 'type': String, 'unique': true }, 'coordinat ...
import bodyParser from "body-parser"; import express from "express"; import mongoose from "mongoose"; import ejs from "ejs"; import multer from "multer"; const app = express(); const port = 3000; app.set( ...
I am encountering a proptype error which is causing an issue with the URL display on my Chrome browser. Instead of showing a proper address, I am seeing the URL as undefined like this: http://localhost:3000/order/undefined Instead of undefined, I should h ...
I have a document containing an array of questions. Each time I click the submit button, I would like a function to retrieve the next question from the array. Essentially, it's a quiz app where questions are stored in a database and all questions are ...
I am seeking guidance on selecting specific data to transmit to my state, as currently it is sending all information when I only require 'firstname', 'lastname', email, and so forth. Below is the NodeJS code snippet for my backend call ...
Is there a way to upload an image from my browser and save it as a local file while also adding the file name to mongodb? I want to be able to retrieve the stored file in the local folder and display it in the browser. Thank you, Babji ...
When I first started using MongoDB, I was able to successfully connect. However, when I tried to execute a basic query like: db.users.find() I encountered an error message saying TypeError: Cannot read property 'find' of undefined, indicating that I cann ...
I recently created an application using ExpressJS, PassportJS, MongoDB with Mongoose, and JSON web tokens. When implementing the successful login route, I encountered the following code: await user.insertLoginTime(); const token = user.generateJwt(); res ...
I am currently attempting to establish a connection between MongoDB and my application within a Docker container. Utilizing the mongoose package, here is the code snippet that I have implemented: mongoose.connect("mongodb://mongo:27016/IssueTracker", { us ...
I am working on creating a user list similar to the image provided below. I am using Angular and Bootstrap for the basics of this project. However, my concern is how to efficiently handle a large number of users. If the user count exceeds 10k, what would b ...
I am currently working with three schemas: const journalSchema = new mongoose.Schema({ title: String, category: String, subcategory: String, review: [{type: mongoose.Schema.Types.ObjectId, ref: 'Review'}], link: String, description: String, s ...
Seeking guidance here. Currently, I am working on a Node.js and MongoDB application related to Apartment ownership. Within this application, there are two main datasets: Ownership and Tenants. For instance, Mr. A owns units 10 and 11. Then we have Mr. C wh ...
1 - What is the recommended order for learning (Mongo db,Node.js,Express)? 2 - Is this platform compatible with both web and mobile devices? 3 - Can you explain the functionalities of the programs? 4 - I'm planning to integrate it into my Flutter mobile ...
This is the HTML form division I have created: <div class="col-lg-2 "> <select name="limitCount" id="limitCount" ng-model="limitCount" class="form-control col-md-2 panel-refresh" ...
I have a unique schema here: const UniqueExerciseSchema = new Schema({ exerciseTitle: { type: String }, logSet: [{ weight: { type: Number }, sets: { type: Number }, reps: { type: Number }, }], }); After obtaining the da ...
It seems like a simple problem, but my brain is struggling to comprehend the issue at 2 AM. I'm working on creating a profile page that displays basic public information. My approach involves retrieving the user's username from MongoDB based on their speci ...