mongodb

Keeping field in mongodb group by

别说谁变了你拦得住时间么 提交于 2021-02-08 11:15:37
问题 I have the following kind of docs in a collection in mongo db { _id:xx, iddoc:yy, type1:"sometype1", type2:"sometype2", date: { year:2015, month:4, day:29, type:"day" }, count:23 } I would like to do a sum over the field count grouping by iddoc for all docs where: type1 in ["type1A","type1B",...] where type2 in ["type2A","type2B",...] date.year: 2015, date.month: 4, date.type: "day" date.day between 4 and 7 I would like then to sort these sums. I know now how to do this (see this question) db

Keeping field in mongodb group by

淺唱寂寞╮ 提交于 2021-02-08 11:14:06
问题 I have the following kind of docs in a collection in mongo db { _id:xx, iddoc:yy, type1:"sometype1", type2:"sometype2", date: { year:2015, month:4, day:29, type:"day" }, count:23 } I would like to do a sum over the field count grouping by iddoc for all docs where: type1 in ["type1A","type1B",...] where type2 in ["type2A","type2B",...] date.year: 2015, date.month: 4, date.type: "day" date.day between 4 and 7 I would like then to sort these sums. I know now how to do this (see this question) db

How to provide server-side pagination with NestJS?

血红的双手。 提交于 2021-02-08 11:03:18
问题 Given a MEVN stack using Nestjs, MongoDB(mongoose) I am working to setup server-side pagination. My approach is to use the mongoose-aggregate-paginate-v2, but I have not been able to distill what I need from my research 1 to make this work within the framework of Nestjs(typescript) and mongoose. Thanks for the assist.. Following documentation on Nestjs mongoose models, and mongoose-aggregate-paginate-v2 setup, I have the following: contact.provider.ts import mongoose, { Connection,

convert mongodb object to javascript object

≡放荡痞女 提交于 2021-02-08 10:54:17
问题 I pass a config file to another node.js module when starting it. The config file contain the following json: "resolution": { "activated": true, "types": [ {"of": 23} ] } When I print the received types array in the called node.js module, it looks like console.log('types array: '+ this.config.resolution.types) //output types array: [object Object] if I tried to print the text by using JSON.stringify() , I get the following result [{"of":23}] My problem start when I try to replace the types

Update only specific sub document deep in nested array of array of documents [duplicate]

流过昼夜 提交于 2021-02-08 10:50:49
问题 This question already has answers here : Updating a Nested Array with MongoDB (2 answers) How to use updateOption with arrayFilters in spring-data mongodb? (2 answers) Update field in exact element array in MongoDB (3 answers) Closed 1 year ago . I have a sample document which has nested arrays like below. { "locations" : [ { "appointments" : [ { "apptId" : "3456", "status" : "" }, { "apptId" : "12345", "status" : "" } ] }, { "appointments" : [ { "apptId" : "12345", "status" : "" }, { "apptId

Update only specific sub document deep in nested array of array of documents [duplicate]

不羁岁月 提交于 2021-02-08 10:48:26
问题 This question already has answers here : Updating a Nested Array with MongoDB (2 answers) How to use updateOption with arrayFilters in spring-data mongodb? (2 answers) Update field in exact element array in MongoDB (3 answers) Closed 1 year ago . I have a sample document which has nested arrays like below. { "locations" : [ { "appointments" : [ { "apptId" : "3456", "status" : "" }, { "apptId" : "12345", "status" : "" } ] }, { "appointments" : [ { "apptId" : "12345", "status" : "" }, { "apptId

convert mongodb object to javascript object

让人想犯罪 __ 提交于 2021-02-08 10:47:23
问题 I pass a config file to another node.js module when starting it. The config file contain the following json: "resolution": { "activated": true, "types": [ {"of": 23} ] } When I print the received types array in the called node.js module, it looks like console.log('types array: '+ this.config.resolution.types) //output types array: [object Object] if I tried to print the text by using JSON.stringify() , I get the following result [{"of":23}] My problem start when I try to replace the types

On EC2, why do I need individual EBS volumes for journal, log, and data?

被刻印的时光 ゝ 提交于 2021-02-08 10:28:50
问题 According to this MongoDB tutorial which explains how to manually deploy MongoDB on EC2, one of the steps states that you should have: "Individual PIOPS EBS volumes for data (1000 IOPS), journal (250 IOPS), and log (100 IOPS)." Why do I need individual EBS volumes for journal, log, and data? Can I just combine these into one EBS volume? 回答1: MongoDB team may have experienced that IOPS needs for data is highest, log is the lowest and journal is somewhere in the middle. Although I am less

CrashLoopBackOff (Mongo in Docker/Kubernetes) - Failed to start up WiredTiger under any compatibility version

落花浮王杯 提交于 2021-02-08 10:27:19
问题 I'm suddenly facing some issues in my Kubernetes application (with no event to explain it). The application has been working properly during one year but now I'm getting a CrashLoopBackOff status. IMPORTANT UPDATE: I cannot update the Mongo replication controller in GKE, because when I commit the changes in mongo.yml (from GIT) all workloads update except mongo-controller (which is down). In GKE in Workloads/Mongo-controller/Managed pods I can see that the "Created on" date is some days ago

how to check if a field exists in a specific document Mongodb using C#?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-08 10:02:00
问题 I have a WebAPI with asp.Net/C# and I'm using Mongodb . Before updating a specific document, I need to check if a field exists in the document or not and if not add the filed to the document. But I don't know how I can check the existence of a field in a document . To add the field I'm using this code: var update = Bundle.Update.Set(b => b.followers, new List<User>()); int res = Bundle.UpdateOne(Bundle.Filter.Eq(b => b._id, id), update); Thanks in advance. I tried to use something like this