Category "mongoose"

How to get decrypted values in the aggregation result by the using of getter and setter in node.js

var mongoose = require("mongoose"); const Schema = mongoose.Schema; let CryptoJS = require("crypto-js"); function encrypt(text) { try { let ciphertext =

Mongoose and MongoDB - Get all countries and users associated with country

So I have a list of posts data that looks like this: [ {user: 'Bob', country: 'USA'} {user: 'Kim', country: 'Mexico'} {user: 'Darren', country: 'Mexico'}

NodeJS with ESM: internal/process/promises:246 | triggerUncaughtException(err, true /* fromPromise */) | finalizer.unsubscribe is not a function

I am creating an observable (RxJS) in NodeJS using ESM. Inside the observable I am performing a query with mongoose. I get the result, but the console returns e

Should we build Mongoose queries on the frontend or backend?

We can build complex queries with Mongoose with options like $lte, $gt, $ne and so on... but I'm wondering where/how we should build those queries? If I have a

How to Insert new documents according to a condition that can be appliyed on one of them

I have a collection where I store unique uID for a user and I also have to register them manually. While registration I pass multiple IDs in an array and now I

Is there a way to cast a string of only hh:mm to Date in Javascript

I have a business hours object in a mongoose schema that represent a date. I'm passing a json object and retrieving the to parse to Date as string. I wonder if

Why can't I connect to mongoDB atlas?

I am new in MongoDB, all my life I used MySQL. I have created an account in atlas, set the IP to my IP and created a user and saved the password. here is my cod

Is there a way to avoid stringValue Favicon.ico error in express js

I am trying to build an application in my Express and anytime i navigate to the admin page i get this error const castError = new CastError();

How to delete and insert with a single command in mongoDB?

So, I have a collection like this: [{ "name":String, "address":String, "hobby":Array of Strings }...] Every hour I query an API and get the response l

Storing sessions with express-session, connect-mongo, and mongoose

I am looking for guidance on setting up session based authentication with with Express-Session, connect-mongo, and Mongoose. Currently it's just generating a ne

Slow query using aggregation framework mongodb

I came up with this code to query a list of questions from db question .aggregate([ { $lookup: { from: "answers", localFie

How to fix " Path is required ,ValidationError " ,Mongoose ,node

I have searched everywhere for this problem. but I cant find the correct way to fix it. help me to what is the problem. const router = require("express").Ro

Specifying a port in MongoDB URI does not allow me to connect to my local DB

I am testing a connection to a local DB using mongoose and mongodb. Whenever I specify a port when passing in the URI to mongoose.connect() I get a connection r

Querying Views with Mongoose (and encapsulating documents fields)

I use mongodb views to encapsulate data in a Data Transfer Object. After the first run of the code below the view is created in the database. Subsequent executi

Querying Views with Mongoose (and encapsulating documents fields)

I use mongodb views to encapsulate data in a Data Transfer Object. After the first run of the code below the view is created in the database. Subsequent executi

Cannot read properties of undefined (reading 'path') - Multer Error

I am uploading an image to a folder in uploads via multer package. I am getting an error while testing the route in POSTMAN. location_model.js const util = requ

How to skip a document from retrieving in MongoRepository if it causes an error?

I'm working on a web application built using SpringBoot as backend and MongoDB as DBMS. I'm showing all the latest posts in a web page. In the PostRepository.kt

How would I able to get search results in elastic search using mongoosastic?

I am trying to use mongoosastic search() but it doesn't give me the result. Data is saved in MongoDB as well as elasticsearch. Below is the mongoose schema cons

Why it's going in else part even there is value in document that satisfying the if condition?

I want to count total number of Documents with same value for details.iseligible.value, i.e if there is two 'Yes' for details.iseligible.value then count for 'Y

Docker Compose MongoDB docker-entrypoint-initdb.d is not working

I am using following docker-compose file version: '3.7' services: db_container: image: mongo:latest restart: always environment: MONGO_INITDB_ROOT_