aggregation-framework

Is there a good way to intentionally cause a slow mongo-aggregation operation?

限于喜欢 提交于 2020-01-16 18:01:04
问题 I'd like to test out some erorr handling code, so I'd like to find a consistent way of causing a slow aggregation operation, ideally without needing a lot of data. For regular mongo queries, {$where: "sleep(10000) && true" } does this well, but mongo aggregations don't support javascript operators. 来源: https://stackoverflow.com/questions/56447145/is-there-a-good-way-to-intentionally-cause-a-slow-mongo-aggregation-operation

Retrieve multiple queried elements in an object array in MongoDB collection

妖精的绣舞 提交于 2020-01-16 12:45:25
问题 I want to find all zone data with "AHU":"C". First, I query without projection and get these. > db.buildings.find({"zone.AHU": "C"}).pretty() { "_id" : ObjectId("5aba4460a042dc4a2fdf26cd"), "name" : "Test Street", "coordinate" : [ 12, 31 ], "yearlyEnergyCost" : 1444, "zone" : [ { "name" : "AHU-C-Z2", "_id" : ObjectId("5aba4460a042dc4a2fdf26ce"), "AHU" : "C", "precooling" : [ ], "subZone" : [ ] }, { "name" : "AHU-D-Z1", "_id" : ObjectId("5abc7528100730697163a3ab"), "AHU" : "D", "precooling" :

Retrieve multiple queried elements in an object array in MongoDB collection

谁说我不能喝 提交于 2020-01-16 12:45:07
问题 I want to find all zone data with "AHU":"C". First, I query without projection and get these. > db.buildings.find({"zone.AHU": "C"}).pretty() { "_id" : ObjectId("5aba4460a042dc4a2fdf26cd"), "name" : "Test Street", "coordinate" : [ 12, 31 ], "yearlyEnergyCost" : 1444, "zone" : [ { "name" : "AHU-C-Z2", "_id" : ObjectId("5aba4460a042dc4a2fdf26ce"), "AHU" : "C", "precooling" : [ ], "subZone" : [ ] }, { "name" : "AHU-D-Z1", "_id" : ObjectId("5abc7528100730697163a3ab"), "AHU" : "D", "precooling" :

Retrieve multiple queried elements in an object array in MongoDB collection

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-16 12:44:48
问题 I want to find all zone data with "AHU":"C". First, I query without projection and get these. > db.buildings.find({"zone.AHU": "C"}).pretty() { "_id" : ObjectId("5aba4460a042dc4a2fdf26cd"), "name" : "Test Street", "coordinate" : [ 12, 31 ], "yearlyEnergyCost" : 1444, "zone" : [ { "name" : "AHU-C-Z2", "_id" : ObjectId("5aba4460a042dc4a2fdf26ce"), "AHU" : "C", "precooling" : [ ], "subZone" : [ ] }, { "name" : "AHU-D-Z1", "_id" : ObjectId("5abc7528100730697163a3ab"), "AHU" : "D", "precooling" :

Lookup pipeline: `$match` local field `$in` array when from value is the array and local value is to be found

丶灬走出姿态 提交于 2020-01-16 09:06:27
问题 I have 2 collections. I want to do an aggregate on Collection A where it matches an ID. From there, I want to lookup from Collection B where the matched ID from Collection A (local field) is in the array of Collection B (foreign field). So basically: Collection A: { _id: ObjectId('<id>') }, { _id: ObjectId('<id>') }, { _id: ObjectId('<id>') } Collection B: { _id: ObjectId('<id>'), related: ['<id>', '<id>', '<id>', '<id>'] }, { _id: ObjectId('<id>'), related: ['<id>', '<id>', '<id>', '<id>'] }

How to filter documents in $match by the last 36 months in MongoDB aggregation

被刻印的时光 ゝ 提交于 2020-01-16 09:06:11
问题 I want to only obtain documents where this specific field "EffectiveDate" is greater than 36 months ago. I have tried: "$match" : {"member.MemberEnrollmentSpans.MemberEnrollmentSpan.EffectiveDate": {$gte: ObjectID.createFromTime(Date.now() - 36*31*24*60*60)}} But It doesn't seem to like the ' ObjectID.createFromTime ' statement, it say my error is at the 'O' position, "Unexpected Character 'O'" Does $match operator not recognize this or is my syntax wrong ? var date = new Date(); (date

Lookup pipeline: `$match` local field `$in` array when from value is the array and local value is to be found

本小妞迷上赌 提交于 2020-01-16 09:06:06
问题 I have 2 collections. I want to do an aggregate on Collection A where it matches an ID. From there, I want to lookup from Collection B where the matched ID from Collection A (local field) is in the array of Collection B (foreign field). So basically: Collection A: { _id: ObjectId('<id>') }, { _id: ObjectId('<id>') }, { _id: ObjectId('<id>') } Collection B: { _id: ObjectId('<id>'), related: ['<id>', '<id>', '<id>', '<id>'] }, { _id: ObjectId('<id>'), related: ['<id>', '<id>', '<id>', '<id>'] }

MongoDB finding nested objects that meet criteria

你。 提交于 2020-01-16 05:04:13
问题 I have a MongoDB document that is structured similar to the structure below follows. I am searching based on people.search_columns.surname and people.columns.givenname. So for example, when I search for the given name of "Valentine", I want to get the document back, but Nicholas Barsaloux should not be included. Data structure: [_id] => MongoId Object ( [$id] => 53b1b1ab72f4f852140dbdc9 ) [name] => People From 1921 [people] => Array ( [0] => Array ( [name] => Barada, Valentine [search_columns

Graphql returns null id for mongoose aggregation query

我的梦境 提交于 2020-01-15 11:43:09
问题 Graphql returns null id for mongoose aggregation query, but works ok other mongoose queries. Here is my mongoose schema: const { Schema } = mongoose; const ObjectId = Schema.Types.ObjectId; const productSchema = new Schema({ _id: ObjectId, price: Number }) const Product = mongoose.model('Product', productSchema, 'Product') Here is my Graphql schema: type Product { id: ID price: String } Graphql normal query: context.Product.findOne() Result with console.log: [ { price: 10, _id:

Graphql returns null id for mongoose aggregation query

你说的曾经没有我的故事 提交于 2020-01-15 11:42:54
问题 Graphql returns null id for mongoose aggregation query, but works ok other mongoose queries. Here is my mongoose schema: const { Schema } = mongoose; const ObjectId = Schema.Types.ObjectId; const productSchema = new Schema({ _id: ObjectId, price: Number }) const Product = mongoose.model('Product', productSchema, 'Product') Here is my Graphql schema: type Product { id: ID price: String } Graphql normal query: context.Product.findOne() Result with console.log: [ { price: 10, _id: