mongodb

Get result of Documents updated from mongoimport

蹲街弑〆低调 提交于 2021-01-29 19:59:00
问题 I'm upserting Documents into a Collection using mongoimport . I'm using shelljs to just run the actual mongoimport command the same way it'd be run through a CLI. E.g. mongoimport docs.json -d DB -c Collection --jsonArray --upsertFields=foo,bar This just outputs the # of Documents updated - but doesn't give any further details on what exactly was changed. However, I need to be able to see which documents were actually updated/inserted and then do something with these results. I would've

Setting Up Facebook Authentication with MongoDB Atlas and Passport.js

佐手、 提交于 2021-01-29 19:09:27
问题 I've done a lot of research to find this answer to my problem, but I haven't discovered anything. Feel free to attach a link if I missed the answer. I did find this solution, but I'm not exactly sure how it might apply to this situation: E11000 duplicate key error index in mongodb mongoose I'm trying to connect my Express.js, MongoDB, Passport.js app to Mongo-Atlas. I have my Atlas cluster set up and accepting new Users from my localhost and using Google Oauth 2.0, however, when I try to

Mongoose: findOneAndUpdate does not update an existing field

送分小仙女□ 提交于 2021-01-29 19:01:24
问题 I am trying to fetch every minute a web API data to MongoDB, save it and update when there is any change. The problem is the volume (every field) field is updated only (happens after a new trading day starts) when the new date is added to ChildSchemaData - subdocumet. All this data is used to build a daily (NOT hourly/minute ) stock chart on front-end. And I am trying to stream it from database but since the volume (and all other fields in subdocument) is not updated in database nothing is

Nodejs application docker unable to connect to mongodb docker container

早过忘川 提交于 2021-01-29 18:54:59
问题 I have a nodejs application which dockerized and need a replicated MongoDB database. I have built my replicated MongoDB in docker-compose and working just fine. if I run the command docker inspect MongoDB-primary |grep IPAddress its print: "IPAddress": "", "IPAddress": "172.18.0.2", now in my application, i give this ip as mongoconnection string(of course with protocol names) but the application cannot connect to MongoDB and throw this error message(application also is a docker container):

How do I retrieve and print pymongo.cursor.Cursor objects?

霸气de小男生 提交于 2021-01-29 18:42:53
问题 I am creating a simple database CRUD manager using python and connecting it to a MongoDB database. I have connected to my cluster and have retrieved posts before using the exact same method. However this time when I tried, it does not work. The error is when I try to print the dictionary object from a collection. The collection only contains a single object with {title:"book"} In the following code, I have retrieved a pymongo.cursor object as the variable name "thedb". print(thedb) will

Mongodb: upsert multiple documents at the same time (with key like $in)

落花浮王杯 提交于 2021-01-29 18:38:25
问题 I stumbled upon a funny behavior in MongoDB: When I run: db.getCollection("words").update({ word: { $in: ["nico11"] } }, { $inc: { nbHits: 1 } }, { multi: 1, upsert: 1 }) it will create "nico11" if it doesn't exist, and increase nbHits by 1 (as expected). However, when I run: db.getCollection("words").update({ word: { $in: ["nico10", "nico11", "nico12"] } }, { $inc: { nbHits: 1 } }, { multi: 1, upsert: 1 }) it will correctly update the keys that are already in the DB, but not insert the

Mongodb - Setting the replication at the db or collection level

大憨熊 提交于 2021-01-29 18:12:33
问题 I come across the following phase and I had fair idea of distributed systems like hdfs and elasticsearch etc .. A replica set in MongoDB is a group of mongod processes that maintain the same data set. Replica sets provide redundancy and high availability, and are the basis for all production deployments. This section introduces replication in MongoDB as well as the components and architecture of replica sets. The section also provides tutorials for common tasks related to replica sets. In all

MongoDB Journal File Size - Relation to Data File Size

落爺英雄遲暮 提交于 2021-01-29 18:12:13
问题 Is there a way to determine the journal file size based on a data file size? For example, I've arrived at a data file size of 10 GB (approximately) based on data + index length considerations and preallocation. I understand journal is also pre-allocated (after every 1GB file size). So, for 10 GB data file, is it possible to assume journal will also be 10 GB? Or is there any other way to calculate it? 回答1: The MongoDB journal files are fixed size 1GB files (unless you use the smallfiles option

System.ObjectDisposedException: Cannot access a disposed object, ASP.NET Core 3.1

≡放荡痞女 提交于 2021-01-29 18:09:22
问题 I am writing an API using SignalR in ASP.NET Core 3.1. I am totally new to .NET Core, and am pretty new to SignalR too. I am having an issue executing MongoDB (Atlas) queries which are running in transactions. It appears that the transaction sessions are expiring before the queries are executing. I'm quite sure it's a async / await issue, but don't seem to be able to fix it. My Hub method looks like this: public async Task<bool> UpdateProfile(object profileDto) { try { ProfileDTO profile = (

MongoDB: Updating every document in a collection

风格不统一 提交于 2021-01-29 17:57:41
问题 How can I add few elements to an array in every document in a collection? I know how to update documents, but I don't know how to update every document in a collection. For example, I have a document like this one: Document { "user": 123456789, "packs": { "normal": 0, "rare": 0, } } Let's say that I updated my bot and now every player should also have a "super-rare": 0 element in his document. How can I achieve this? I'm using MongoDB Atlas 回答1: You can get this done with simple update. If