mongodb

Node js form submit TypeError: Cannot set property 'userId' of undefined

淺唱寂寞╮ 提交于 2021-01-29 13:09:46
问题 I have added login and registration features to a page in my application in views/employee/login.hbs. When I enter in registration details (email, username, password and conf password), I hit the register button to hopefully be redirected to the views/employee/home.hbs page. However, when I complete this action my MongoDB Compass Community database receives the registration details that I have entered successfully but my browser states 'The site cannot be reached' and URL is "localhost:3000

front end react is not sending data to to mongoDB database

久未见 提交于 2021-01-29 13:02:16
问题 THE app is suppose to register the new user and send the new users info to the MongoDB, but when i attempt to register the user it throws an error of 500 internal error. the console says the error is in the user file, the terminal say this is the error, Proxy error: Could not proxy request /api/users from localhost:3000 to https://localhost:5000. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (EPROTO). I've already tried changing the proxy in the

MongoDB filter nested array

北城以北 提交于 2021-01-29 12:20:55
问题 I have a collection that looks something like: [ { "_id": 1, "title": "dummy title", "settings": [ { "type": "light", "status": "enabled" }, { "type": "flare", "status": "disabled" }, { "type": "toolbar", "status": "enabled" } ] } ] I wanna fetch it by Id but only with the "enabled" settings and not sure how the aggregation pipeline should look like. I supposed to create the query using mongoTemplate in Java / Kotlin but even just the mongo query would be enough. 回答1: You can do it with a

How to get the number of connections used (and free) to the MongoDB (from a client perspective)?

我的梦境 提交于 2021-01-29 11:59:40
问题 I'm posting the question here just to be sure I'm not barking on the wrong tree. How to get the number of connections used (and free ) to the MongoDB, but from a client perspective (eg. Java client), using the 4.x driver? There are posts regarding using the serverStatus(Get the number of open connections in mongoDB using java), but it presumes having 'admin' access to the MongoDB. Using a 'regular user'(an db user with lower privileges (e.g access to only one database)) cannot run the

Find duplicate urls in mongodb [duplicate]

回眸只為那壹抹淺笑 提交于 2021-01-29 11:42:47
问题 This question already has answers here : Find duplicate records in MongoDB (4 answers) Closed 10 months ago . I have a DB with news articles, and I am trying to do a little DB cleaning. I want to find all duplicate documents, and the best way i think to accomplish this by using the url field. My documents are structured as follows: { _id: author: title: description: url: urlToImage: publishedAt: content: summarization: source_id: } Any help is greatly appreciated 回答1: Assuming a collection

Spring boot + Mongo listener , does not allow tomcat to start

吃可爱长大的小学妹 提交于 2021-01-29 11:41:02
问题 I have a spring boot application , where is deployed on multiple nodes. I want to write a mongo listener inside my spring boot application to do this, as I listen to db events and burst my inmemory cache. The problem is when I write a listener as below, my tomcat startup does not happen at all, only event listener starts: @Component public class MongoListener { @PostConstruct public void listenProduct() { MongoClient mongoClient = new MongoClient(new MongoClientURI("mongodb://localhost:27017"

mongo docker image not running script after created

荒凉一梦 提交于 2021-01-29 11:27:10
问题 I'm using docker-compose to create 3 diferent containers for a frontend, backend and mongo instance. the 3 of them are running and connected between them, but I need to create an admin user on DB as soon as the mongo instance is running. According to mongo image documentation every script located on docker-entrypoint-initdb.d should be run after the instance is created. As I already said I'm using docker compose so theres no Dockerfile for mongo, just a service using the official mongo image

Mongo Express Error while using Basic Auth in Kubernetes

你说的曾经没有我的故事 提交于 2021-01-29 11:19:19
问题 I am deploying a mongo-express pod in my kubernetes cluster in order to have a quick view of my db data. I can use mongo-express normally if I do not config basic auth. However, when I add the basic auth configuration to my Deployment yaml file. It has the below error that showing on website directly. Error: Server Error The server encountered a temporary error and could not complete your request. Please try again in 30 seconds. I am using Kubernetes cluster and I use Ingress to expose mongo

How to add item to mongoose Array

南笙酒味 提交于 2021-01-29 11:00:23
问题 I'm developing a web app that uses mongodb database using mongoose in node.js... Now, I'm trying to build the rate feature, in this feature, people can rate the store and give some comments about that store. This is the structure: rate: { author: req.body.author, text: req.body.text } To update it I'm using the "findOneAndUpdate" function, but, Always when i do it, the existent rate is overwritten by the new... Can you guys help me? 回答1: Here you can do. I am just demonstrating with example

How to query against fields of array of objects in mongodb?

拟墨画扇 提交于 2021-01-29 10:51:23
问题 I have a mongo collection which has the following document: { _id: ObjectId("5c7ba3c0e30e6132f8b0c4ef"), replies: [ { _id: ObjectId("5c7ba3c0e30e6132f8b0c4ef"), status: 'rejected' } ] } I want to get all replies with status approved so I make the following query: Collection.find({'replies.status': 'approved'}) and yet the document above appears in the results. What am I doing wrong? 回答1: This is a common misunderstanding of the query process. I suspect one of your docs looks like this: { "_id