Category "mongodb"

Importing data into MongoDB Atlas

I have a local database/collection that I created from an external .bson file using mongorestore. I'm able to access the collection from my local machine, howev

MongoDB/DocumentDB bson_append_array(): invalid array detected. first element of array parameter is not "0"

Recently I have migrated one of my projects (PHP 7.4/Lumen/Ubuntu 20.04) from MongoDB to MongoDB compatible AWS DocumentDB. Since the migration all the CLI Scri

Migrating to MongoDb Atlas from Local

I'm trying to migrate my local MongoDB over to Atlas. I managed to run the mongodump command with localhost and can see the files in ./dump/data.bson However,

Node.js Large File Uploads to MongoDB blocking the Event Loop and Worker Pool

So I want to upload large CSV files to a mongoDB cloud database using a Node.js server using Express, Mongoose and Multer's GridFS storage engine, but when the

Multer not adding file extension

I'm working on a Node.js/MongoDB based website and i'm trying to upload images directly on server using Express, Jade, and Multer, but no matter what i do, i ca

How to convert current datetime into given timezone and store in MongoDB & fetch in DD-MM-YYYY HH:mm format?

My local time is 'Asia/Kolkata.' And I have to convert the current DateTime into 'Pacific/Auckland' and store it into MongoDB And on fetch I have to format this

Can't Connect Mongoose to MongoDB - There is no established connection with mongoose and a mongoose connection is required

I was looking around in Discord.JS and creating a bot, but every time I want to turn on the bot, ( using node index.js) this error happens: throw new Error("Th

RoboMongo can't use array filters?

Following on from "How to update collection and increment hours for ISO date". It seem that RoboMongo can't execute a query with an array filter: This same

Issue with Arbiter feature compatibility after upgrade of replica set of two nodes with Arbiter to 3.6

I have upgraded MongoDB replica set to 3.6 following this instruction https://docs.mongodb.com/manual/release-notes/3.6-upgrade-replica-set/. When I executed co

MongoDB: subtract months from date, with value from database

Is it possible in MongoDB to somehow subtract only months from a date, with a value from the same document. So for example i have to subtract date from field "v

Find by _id on an array of objects in mongodb database

I'm trying to find the id of an object inside an array of objects. That _id has the same field name _id as others in the document. This is my model (brief) var

Failed to start mongod.service: Unit mongod.service not found

I follow all the steps mention in MongoDB installation documents for Ubuntu 16.04. Steps 1: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv

MongoDB command, mongod, is not functioning and closes itself

Posted below is my bash command line execution of mongod. I am not sure why it is not working properly and is resulting in the series of key:value pairs, follow

FindIterable<Document> how to get total records in a result of a query

I was using mongo driver for java 2.x and passed to 3.1. DBCursor is deprecated and I had to use the FindIterable<Document> structure. When I perform a q

FindIterable<Document> how to get total records in a result of a query

I was using mongo driver for java 2.x and passed to 3.1. DBCursor is deprecated and I had to use the FindIterable<Document> structure. When I perform a q

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