Category "mongodb"

MongoDB - Error: document must have an _id before saving

I've been struggling so much with this project. I am following a tutorial that is out of date in some areas, for instance their version of Jquery used a totally

Mongoose: Get full list of users

I have tried to use Mongoose to send the list of all users as follows: server.get('/usersList', function(req, res) { var users = {}; User.find({}, fun

Getting error while running the aggregate method of MognoDB

I am getting the following error while joining two collection and project the fields using MognoDB. Error:: Error: command failed: { "ok" : 0, "er

How to read a specific key-value pair from mongodb collection

If I have a mongodb collection users like this: { "_id": 1, "name": { "first" : "John", "last" :"Backus" }, } How do I retrieve name.first from

mongodb set field value using if else during document update

Is there a way in mongodb to use if/else to set a field value during an update. i know that i can use find, to return documents, loop over them, and do if/else

mongodb update/upsert that adds data to the existing document instead of replacing data in an existing document

I am using an upsert using mongodb's Jensseger PHP library. Every time I add new data to the document it updates the value of the field if the field names are

MongoSocketOpenException - trouble with connecting to MongoDB

This is my first time trying anything with MongoDB, so I would love any tips if you guys have any, but in particular, Im having trouble establishing a connectio

Performing a HTTP POST request in Node with MongoDB/Mongoose?

I have defined my schema, I just need to know the syntax to do the actual HTTP POST request. I am using MongoDB with Mongoose framework. This way when I go to m

MongoDB: Find the minimum element in array and delete it

I have a documents in MongoDB, one of them looks like this: { "_id" : 100, "name" : "Something", "items" : [ { "item" : 47, "color" : "red"

Specify raw aggregate request with Spring Data Mongodb

I write a big aggregate query for mongodb, now I try to translate it in Spring Data Mongodb API, and it's very complicated, and spring data api did not help me

How to find items in a collections which are not in another collection with MongoDB

I want to query my mongodb to perform a non-match between 2 collections. Here is my structure : CollectionA : _id, name, firstname, website_account_key, emai

Mongoose - remove multiple documents in one function call

In documentation there's deleteMany() method Character.deleteMany({ name: /Stark/, age: { $gte: 18 } }, function (err) {}); I want to remove multiple documents

How to do type conversion when transferring data from MongoDB to kafka with debezium?

In Mongodb, the objectid is base64. I'm streaming these docs to Kafka using Debezium. How can I get ObjectId to be written as UUID in kafka? Mongo Example Doc :

mongo - insert documents to other collection based on query

I am trying to insert documents to a collection based on a query So I wrote the query, and then for each, How do I read info from the "doc" result document from

com.mongodb.MongoTimeoutException when using MongoClient with list ServerAddress

I'm trying to deploy a replica database onto one server with different port and connect with it. Everything is ok if I just use single ServerAddress and connect

In MongoDB, method to keep the previous value of a field in a different field while updating an object?

Say I have an object with field state, I want to update this field, while keeping the previous value of state in previous_state field. First, I have tried to ma

MongoDb error: cannot use 'j' option when a host does not have journaling enabled

I was using mongo in dev just fine, when deploying the app into test env I got this error when objects are saved in the application cannot use 'j' option when

Find duplicate records in MongoDB

How would I find duplicate fields in a mongo collection. I'd like to check if any of the "name" fields are duplicates. { "name" : "ksqn291", "__v" : 0

Compose Transporter throws error when collection_filters is set to sync data for current day from DocumentDB/MongoDB to file/ElasticSearch

I am using Compose Transporter to sync data from DocumentDB to ElasticSearch instance in AWS. After one time sync, I added following collection_filters in pipel

What's the fastest way to copy a collection within the same database?

I want to copy a collection within the same database and give it a different name - basically take a snapshot. What's the best way to do this? Is there a comm