Questions tagged [mongodb]

MongoDB is a scalable, cross-platform, high-performance, open source, document-oriented NoSQL database. It supports a large number of languages and application development platforms. Questions about server administration can be asked on https://dba.stackexchange.com

mongodb
Filter by
Sorted by
Tagged with
1 vote
2 answers
38 views

Check for similar collection withing a collection then add or Update MongoDB

so i am trying to select a specific array from my department-> dStock collection. i want to select it like i would any other data fields in my initial collection and edit or delete it or simply ...
Rick Hamton's user avatar
0 votes
0 answers
37 views

Can't read property of undefined mongoose/mongo

You can check this link for full code here > function seedDB () { Campgrounds.remove({},function(err){ if (err) { console.log(err); } else { console.log("...
ripped guy's user avatar
1 vote
2 answers
566 views

Amazon Document DB: How to Implement multi-document transactions

When using mongo template to start a session for transaction in document db cluster. public class DocDBService() { @Autowired MongoTemplate mongoTemplate; @Autowired MongoTransactionManager ...
Mukundhan's user avatar
  • 3,353
1 vote
0 answers
33 views

Trouble passing MongoDB document to HTML (Flask & Pymongo)

I am having trouble passing a document from my MongoDB database to an HTML file I have rendered using flask. My database is called users and has fields "_id", "name", "...
rachelo's user avatar
  • 41
0 votes
2 answers
2k views

Mongoose and Nodejs get the name of a user by there ids

I am new to Mongoose and couldn't find an answer elsewhere. I have a user schema like this: const userSchema = new mongoose.Schema({ name: { type: String, required: true }, ...
alec wilson's user avatar
0 votes
1 answer
1k views

MongoDb convert Datetime stamp to date in collection

I have few dates in my collection "workedDate" : ISODate("2020-07-02T08:16:59Z"), "workedDate" : ISODate("2020-07-01T14:00:00Z"), "workedDate" : ...
Shaleesh Madhavan's user avatar
0 votes
2 answers
520 views

Mongoose - Count only above a certain value

I'm new to mongoose, and I'm wondering how you would do the SQL equivalent of this in mongoose! SELECT COUNT(balance FROM users WHERE balance > 1; (or something very close to that) I can't see ...
New Coder's user avatar
1 vote
2 answers
1k views

Using a variable inside mongoose find() Query

I'm trying to work with mongoose to implement a simple search feature that I plan to expand later. Basically what I'm trying to do is take a search query from the user and put it inside the mongoose ...
Mahmoud Ashraf's user avatar
0 votes
1 answer
671 views

MongDB: Query to extract dynamic key, value pair from nested documents

The below-given is my data structure, I have a requirement to extract "publishers" dynamic keys and compare ($lookup) with another collection for matching records, sum the % values. "...
pyborg's user avatar
  • 166
1 vote
0 answers
185 views

How to do a stored procedure/ function in MongoDB

I'm new to mongo and I could make this from aggregate but I want to make a function / or kind of a stored procedure using these two tables and it should content Customer CUSTOMER_NO, FNAME, LNAME, sum(...
rra's user avatar
  • 809
1 vote
1 answer
543 views

mongoose: getting unknown objectId when stored string instead of objectId

According to me when i pushed 'ABC' instead of objectId, It should show some error like Cast to ObjectId failed for value "ABC" at path "likes". but when i print that updated ...
Ishwar Chandra Tiwari's user avatar
1 vote
0 answers
516 views

Deleting todo list item only works for top item on list

So I have a simple todo list page and each item on the list is accompanied by a checkbox that when checked should remove the item from the list. However, this functionality only works for the top item....
Zack's user avatar
  • 23
0 votes
0 answers
176 views

Mongodb-Nodejs Pull Element From An Array

Guys I want to $pull an element from array. Here: User's Follow: { follow: [ 5edfe8f3bfc9d677005d55ca, 5edfe92fbfc9d677005d55cc, 5ee2326cc7351c5bb0b75f1a ], follow id:(Which we will pull)...
Ö. ALP EREN GÜL's user avatar
2 votes
0 answers
414 views

'Error: cyclic dependency detected' when deploying to Heroku with a MongoDB Atlas Cluster

I tried to deploy a Node.js app to Heroku using Heroku CLI. However, I get an Application error with the following stack: 2020-07-04T13:27:53.894161+00:00 app[web.1]: 'Error: cyclic dependency ...
nathaner's user avatar
  • 493
2 votes
0 answers
153 views

Is there a way to have a function that supports the polymorphic properties of both GraphQL and Mongo in Go?

I'm working on a Go application that utilizes gqlgen (GraphQL code gen) to communicate with the client, and MongoDB as the backend database. For our GraphQL schema, we have several types of games (...
CarsonS5's user avatar
1 vote
1 answer
97 views

error when trying to update mongodb using a flask variable for the fieldname

I am working with flask trying to update a mongodb collection which works fine when I state the fieldname that needs updated, but I want to fieldname to be a variable depending on which needs updated. ...
Aristotle's user avatar
  • 131
0 votes
1 answer
38 views

how to remove sessionID:null value objects from the array nested inside the array of objects in js

[ { "_id": "5edfb4e587a1873120735dcf", "firstname": "abc", "lastname": "abc", "sessions": [ ...
Paras 's user avatar
1 vote
0 answers
71 views

How to create complex nested documents using mongoose?

I want to create a complex nested document which can store values like this category: { "fish": ["Sardines", "Goldfish"], "dogs": ["German Shepherd&...
onMyWay's user avatar
  • 117
0 votes
1 answer
2k views

FindOneAndUpdate MongoDB with Mongoose updating user's profile not working with email?

I'm building a REST API in Express JS and Mongo DB. I'm utilising the Mongoose package to interface with the database and am trying to implement a robust endpoint for allowing a user to update details ...
Ryan H's user avatar
  • 2,742
0 votes
3 answers
2k views

User.findOne returns null

router.post("/login", async (req, res) => { try { console.log(req.body.email) const user = await User.findOne({email: req.body.email, password: ...
user avatar
0 votes
2 answers
79 views

Why can't I access the elements of this object in Javascript?

I'm working on a simple hobby project after finishing a Udemy course on web development, and I'm having some issues with a simple middleware I've written. The function in question goes as follows: ...
Joseph Morgan's user avatar
3 votes
2 answers
10k views

toObject is not a function error while converting mongoose object

I have a route '/login' which has controller to verify user is valid. For now, i am just verifying password entered from route params equals to password i stored in my DB. I have few methods to get ...
kalyan veenam's user avatar
1 vote
1 answer
123 views

MongoDB nested array group by Multiple values

I have a nested array that I want to group according to branch, department, and product. For each of these products, I want to get the sum of the quantity. This is my array: const array = [{ ...
LeoGarcia's user avatar
0 votes
1 answer
55 views

can use the method of pymongo to obtain securities occupation funds and securities quantity?

I have a mongodb data like below:      code date     num price money 0 2 2015-11-15 10 3.8 -38.0 1 2 2015-11-17 -10 3.7 37.0 ...
netsee's user avatar
  • 35
0 votes
1 answer
104 views

Why does my express route works when I write it in first, else it shows cast error?

I've got a friend route which I registered on the user route. I've registered the user route in the app, I've used mongoose.Types.ObjectId in the user schema Mongoose Version: 5.9.19 In User.js router....
anotherChowdhury's user avatar
0 votes
1 answer
88 views

Query between two values in mongoose considering all posibilities

So, I don't know how to describe the problem on a question, so here's the example: Let's say I need to check out I need to make an appointment at this given time: startsAt: 8, endsAt: 11 But, these ...
Robert Arias's user avatar
0 votes
0 answers
375 views

CastError: Cast to ObjectId failed

Here are some of my snippets of code: app.js: var express = require("express"), app = express(), mongoose = require("mongoose"), bodyParser = require('body-parser'),...
Ujjwal Kirti's user avatar
0 votes
1 answer
287 views

Querying a collection with matching IDs from an array of JSON objects with Mongoose

I have a database collection where each row has a unique ID associated with it. I want to be able to query my database and match data from it with the IDs in each of the objects from an array. The ...
Josh Bounce's user avatar
2 votes
1 answer
6k views

Remove specific object from array during aggregation

I have documents with the following structure: {field: ["id1", "id3"]}, {field: ["id2", "id1"]} To query the documents I use aggregate({$match: {'field' : { $...
Kristbp2's user avatar
5 votes
1 answer
636 views

MongoDB Realm has [error exchanging access code with OAuth2 provider]

I am currently creating a simple app with the purposes are: Sign In with Google through GoogleSignInSDK then get the token from google, and use that for io.realm.mongodb.Credentials.google(token). ...
Tran Thanh Trong's user avatar
0 votes
1 answer
48 views

how to handle async function that return promise?

I want to get a user from MongoDB. so I should use the async function to get the right result. but it return me [object , promise]. how can I use this data? async function getUsers() { var ...
Saeedeh's user avatar
  • 297
1 vote
1 answer
37 views

I want to create a last clock filter pymongo

I'm making a website. I write the all data I get from the database as a list. I want to make a filter. I just want to get the data in the last hour. @app.route('/task/list/birsaat', methods=['GET']) ...
adobean's user avatar
  • 332
0 votes
2 answers
199 views

Return a collection of objects with the same date (MongoDB/Mongoose)

Given a collection looking like this { "uuid" : "32645503-0d51-4fc6-8e4a-28b03714db5e", "date" : "1593701241361" } { "uuid" : "63022d8b-e16e-4387-...
user avatar
0 votes
3 answers
896 views

MonogDB C# Driver LINQ query not working when filtering by _id

I am currently trying to build a web API that interfaces with MongoDB using the C# driver. The GET route uses several optional parameters that dynamically generate the LINQ query based on which ...
mschurr's user avatar
0 votes
1 answer
109 views

Mongo DB UpdateOptions | No array filter found for identifier 'id' in path 'Display.$[id].DpDay.$[day].note'

Note. At the List "DpDay" is empty. I want to enter an item, If not exists. ArrayList<Bson> cOption = new ArrayList<>(); cOption.add(Filters.eq("id._id", ...
ru4ert's user avatar
  • 1,114
0 votes
1 answer
2k views

How to filter a MongoDB/Mongoose query based upon referenced subdocuments values

So I am currently working on cloning some app concepts (for learning purposes) and I have built a basic social media app that has users, posts, & allows users to block users if they don't want to ...
Paper Krane's user avatar
0 votes
3 answers
51 views

React.js Failed to compile: unexpected token

everyone. I keep getting this error, and I don't know whats wrong: Error message It says that there is an unexpected token and that there has to be a comma somewhere. Can somebody tell me, whats wrong ...
Elina D.'s user avatar
0 votes
1 answer
134 views

sort array before using mergeObjects MongoDB

I am doing a query in mongo db where I group some documents and I need to merge objects, but the objects has a key of date and I would like to sort the documents before merge objects to have the last ...
AlexisMunoz's user avatar
0 votes
1 answer
33 views

How do I open the MongoDB out? How to make authorization only for external clients?

All of you since Friday night! Help Nuba, there is a backend on Node.js that uses local MongoDB and you need to throw Mongo outside. In bindIp it already costs 0.0.0.0, but no miracle happens. Plus ...
HtmlMan's user avatar
  • 55
0 votes
1 answer
762 views

reactjs - adding friends to InnerCircle list

I have a list of friendsboxes with each friendsbox a button that should add the friends assign to the InnerCircle list. In the friendsDetail component the addToInnerCircle should add the friend's ...
charlesbxl's user avatar
1 vote
0 answers
194 views

MongoDB $push aggregaton won't keep the right order

I tried to make a $group aggregation with MongoDB, like the following example: "$group": { "_id": "$test_id", "feeling": { ...
Ma G's user avatar
  • 25
3 votes
1 answer
7k views

What is the use of Nodejs mongodb driver keepAlive option?

I'm having hard time understanding keepAlive option passed to nodeJS mongo driver. this docs says keepAlive takes boolean value and keepAliveInitialDelay is used to wait before initiating keepAlive on ...
mahendra's user avatar
  • 197
0 votes
1 answer
95 views

Mongo DB clone on different Host IP but same server?

Here is the situation: I have an iOS app that runs with a Mongo DB. The iOS team who is working on my backend code, has created an extra /dev folder on the live server where they are currently, ...
Sammuel's user avatar
  • 27
0 votes
1 answer
190 views

MongoDB Replica Set Snapshot with Lambda Function best practice

I'm quite new to MongoDB and a bit confused. I'm trying to create on AWS an automated backup routine to be used in production, and I want to make sure I'm doing it correctly. By now I have set a ...
fasenderos's user avatar
1 vote
1 answer
6k views

Mongoose: Invalid value for schema Array path, got value "undefined"

I have the following probelm that elements is undefined when make it equal to a Schema. the element courses in Course.js is undefined. User.js file: const mongoose = require("mongoose"); ...
Hoang's user avatar
  • 79
0 votes
1 answer
324 views

How to update hours in data field in mongodb

I have set of mongo document, I need to convert/update the below values like ("workedDate" : ISODate("2020-07-01T00:00:00Z")) "workedDate" : ISODate("2020-07-01T20:...
Shaleesh Madhavan's user avatar
0 votes
3 answers
139 views

Multi condition to filter the document in mongodb according to subdocument array

I need to filter all documents by using multiple conditions. { "name": "Maths", "excludeUserIds": [ { "_id": 33, "...
user avatar
0 votes
2 answers
115 views

I cannot render the data from my db in React.js project "TypeError: Cannot read property 'title' of undefined"

I'm using Axios to get data from my API but when I try to render the state out I get an error of : "TypeError: Cannot read property 'title' of undefined". I used the same code for a previous ...
andrPau's user avatar
  • 229
1 vote
1 answer
212 views

Serverless Log in and registration

Im new to using the serverless framework and I need to make a log in page and registration in my React js app. I'm using MongoDB and Serverless as my api. Could someone point me in the right direction ...
Zijah's user avatar
  • 31
0 votes
1 answer
283 views

I can connect to MongoDB, but when I create a cursor with iterable.iterator() I get com.mongodb.MongoTimeoutException

String user = "readonly"; // the user name String database = "example"; // the name of the database in which the user is defined char[] password = "example&...
user avatar

1
963 964
965
966 967
3521