mongodb-query

MongoDB - Find documents matching certain condition for unknown field keys

谁说胖子不能爱 提交于 2020-12-12 12:13:38
问题 How can I query a MongoDB collection to find documents with a structure as below? The documents have a field called thing which is a subdocument, and the keys for this field are a form of ID number which will generally not be known by the person writing the query (making dot notation difficult and I assume impossible). { "_id" : 3, "_id2" : 234, "thing": { "2340945683": {"attribute1": "typeA", "attribute2": "typeB", "attribute3": "typeA" }, "349687346": {"attribute1": "typeC", "attribute2":

In MongoDB, how do I perform a $geoWithin query as part of an aggregation pipeline that utilizes $lookup?

爱⌒轻易说出口 提交于 2020-12-12 02:00:10
问题 I'm trying to use an aggregation pipeline to determine whether a specific territory has specific territories that match $geoWithin . Each territory has a geojson geometry object that is indexed appropriately. I'm not sure I am using let properly in this pipeline or if there is a way to coerce MongoDB into recognizing the parameters as appropriate geojson . I get the following error with the pipeline below: unknown GeoJSON type: { type: "$$type", coordinates: "$$coords" } const

In MongoDB, how do I perform a $geoWithin query as part of an aggregation pipeline that utilizes $lookup?

隐身守侯 提交于 2020-12-12 01:59:10
问题 I'm trying to use an aggregation pipeline to determine whether a specific territory has specific territories that match $geoWithin . Each territory has a geojson geometry object that is indexed appropriately. I'm not sure I am using let properly in this pipeline or if there is a way to coerce MongoDB into recognizing the parameters as appropriate geojson . I get the following error with the pipeline below: unknown GeoJSON type: { type: "$$type", coordinates: "$$coords" } const

MongoDB - finding entries using a nested dictionary

纵饮孤独 提交于 2020-12-05 10:30:09
问题 I have a MongoDB that I use with python. My entries that looks as follows: { a: something b: something c: { d: something e: something f: something } } I want to query for entries that have a specific values for d and e but I don't care about the value in f. I tried not specifying f at all (similarly to when I don't care about the b value where I just not adding it to the query): { a: a_value b: b_value c: { d: d_value e: e_value } } I also tried to use: { a: something b: something c: { d:

MongoDB - finding entries using a nested dictionary

馋奶兔 提交于 2020-12-05 10:29:12
问题 I have a MongoDB that I use with python. My entries that looks as follows: { a: something b: something c: { d: something e: something f: something } } I want to query for entries that have a specific values for d and e but I don't care about the value in f. I tried not specifying f at all (similarly to when I don't care about the b value where I just not adding it to the query): { a: a_value b: b_value c: { d: d_value e: e_value } } I also tried to use: { a: something b: something c: { d:

MongoDB query IN array of object

自作多情 提交于 2020-12-04 19:55:40
问题 I have problem to retrieve information between two collections. The first collection stores employees information: { "_id" : ObjectId("4f9643967f8b9a3f0a00005a"), "birth_date" : "1963-09-09", "departments" : [ { "departments_id" : ObjectId("4f9643957f8b9a3f0a000007"), "from_date" : "1990-01-03", "to_date" : "1990-01-15" } ], "first_name" : "Parviz", "gender" : "M", "hire_date" : "1990-01-03", "last_name" : "Lortz", } the second one the departments information { "_id" : ObjectId(