Category "mongodb"

Slow MongoDB aggregate with $sort on _id field

I have a records collection with the following indexes: {"_id":1} {"car.make":1,"city":1,"car.mileage":1} And performing the following query: db.records.agg

How to disable MongoDB deprecation warnings

I use Node with Monk, a simple library for MongoDB. It doesn't have insertOne and so on. And it's totally annoying to get a deprecation warning on each insert.

Find balance from debit and credit entries mongodb

I have a Mongo collection like this: { "user_id" : "1", "branch_id" : "1", "trans_type":"DEBIT", "total" : 500 }, { "user_id" : "1", "b

Push items into mongo array via mongoose

Basically I have a mongodb collection called 'people' whose schema is as follows: people: { name: String, friends: [{firstName: String, lastN

Mongoengine raw find_and_modify query gives "Must either update or remove" exception

I am using Django + mongoengine I want to update the books (embedded document) count in my Bookscollection document. I want the update query to return the full

how to download a file saved in gridFS using nodeJS

I need to download a resume from GridFS, below is the code ive written to do it, but this seems to not give me a physical file for download, this is used to rea

How to stream data from mongodb in Structured Streaming?

Is it possible to use spark structured streaming to read data from mongo db with a readStream ? For standard use of structured streaming, I usually do so: va

Connection Not established in Mocha to MongoDB Atlas

When starting my application it connects to MongoDB Atlas as logged, however, when running mocha tests it does not even try to connect to the DB. here is my ser

zsh: command not found: mongo

I'm following the official instructions found here (on Mac OS Big Sur): https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ When attempting to run

Java Mongodb regex query

I have to run this query in Java db.Users.find({"name": /^ind/i}) My Java code is Document findQuery = new Document(); findQuery.append("name", Pattern.co

Mongoose won't update new field after updating schema declaration

I just noticed that when i update my schema definition and add a field, for instance "name: String" and then try to use People.update( { _id: user_id }, { $se

MongoDB Compass Visually Insert Sub-Document

I'm using MongoDB Compass to visually build my collection. In the highlighted section, I don't see a "Document" type to insert a sub-Document. Am I doing it th

how can i make BCryptPasswordEncoder() work in spring because in my application can't find that classes

how can i make BCryptPasswordEncoder() work in spring because in my application can't find that class about that and the message is not matching for dependenci

Create a user in MongoDb using powershell

I'm using MongoDb v3.0.3 and want to create a user in a database with admin privileges using powershell. I hook into the C# driver but I don't get very far: $p

MongoserverError: bad auth: authentication failed problem

I correctly use the username and password in the url of vs code for my server side but in the cmd i find the error of mongodb authentication fail. why this is h

Is there any way to implement pagination in spring webflux and spring data reactive

I'm trying to understand reactive part of spring 5. I have created simple rest endpoint for finding all entities using spring web-flux and spring data reactive

mocha wait for db connection before running tests

Basically to run the tests, I need the database connection to MongoDb to be ready. The database manager has a connect method to get a connection and a get metho

How to use User.findOne({ userID: searchUserID } correctly ??? (currently not getting return value)

I am currently trying to implement an update / put functionality in my node.js-project and having issues I have absolutely no clue, where that comes from. (also

Convert string to ISODate in MongoDB

I am new to MongoDB and I am stuck on the String to Date conversion. In the db the date item is stored in String type as "date":"2015-06-16T17:50:30.081Z" I wa

formidable - SyntaxError: Unexpected token - in JSON at position 0 when sending POST request

I am building the backend for creating blog posts for my web application while following a tutorial. The technologies I am using are MongoDB, express.js, formid