Questions tagged [mongodb-query]
This tag is for questions related to querying and updating MongoDB collections, either through the mongo shell or using a programming language driver.
mongodb-query
17,503
questions
0
votes
0
answers
38
views
Spring Data MongoDB Aggregation - Invalid Reference Error
I am working on a Spring Data MongoDB Aggregation Pipeline. The pipeline has multiple stages (match, unwind, project, group, addFields, etc.).
At all these stages, I just pass (totally undisturbed) an ...
1
vote
1
answer
62
views
MongoDB $lookup on multiple conditions: join with empty array field
I have two collections,inf and data.
inf sample:
{
"_id": {
"$oid": "662bb5218bd38ee73cd579f0"
},
"point": 12,
"code": "bc010",
...
0
votes
0
answers
37
views
Mongodb: Error: Failed to create couple: Operation `couples.insertOne()` buffering timed out after 10000ms
I have mongodb setup locally and I created a database with a collection couples. I verified this using mongosh:
This is the code that connects to the database:
databaseConfig.ts
import { ...
0
votes
2
answers
43
views
Aggregator Query for complex mongoDB Structure
`I am trying to write an aggregator query for the complex DB document below, ideally i am looking for creating multiple streams from the given activities set, identifying the parent child hierarchy ...
0
votes
0
answers
51
views
field indicating last modification of a documont in mongodb
I am building an API over my mongodb cluster. Each call for the API should return only the newest values or the values that have been modified seen the last call. I thought i need to add a field to ...
0
votes
0
answers
24
views
MongoDB, how do I speed up my geo-query for a large collection (~20M docs)?
I have a colleciton with ~20M entries. Each document being a GeoJSON object with the following format:
_id: ObjectID,
properties:
-gml_id: String,
-....
-<A few other properties that don'...
2
votes
1
answer
49
views
Mongo query: find document where each embeded element equals to given value
I have a collection with embedded array of objects. I need a query to select only those documents where each of embedded objects prop equals to some value:
{
{
_id: 1,
objects: [{...
0
votes
0
answers
41
views
MongoDB driver Linq Last operation not supported
I am using MongoDB driver 2.19.0. In Mongo collection, document has 1 list of statuses and I want to sort all documents based on the last element of statuses list.
So sort query is
orderbyquery = s =&...
2
votes
2
answers
49
views
MongoDB aggregation: Only keep the running total for the last item in the partition
I have a data like:
[
{ "grp": "A", "seq": 1, "score": 1, x: 0 },
{ "grp": "A", "seq": 1, "score": 2, x: 0 },
{ &...
0
votes
3
answers
72
views
Decrement value MongoDB, prevent negative number
I'm using MongoDB and I have a document where I want to increment a count field. However, I need to ensure that this count does not go below zero. For example, if inc is -2 and the current count is 1, ...
0
votes
0
answers
18
views
Lookup fails when do the match in the pipeline in mongodb
I am trying for a query with lookup crops (with fields, cropid, cycleStartDate) and harvest (with fields harvestDetails.harvestDate, harvestDetails.pieces).
Kindly help me in the lookup when its match ...
0
votes
0
answers
27
views
Unable to determine the serialization information for DateTime
I am trying to run mongoDB query in c#. I need to get records in descending order of UpdatedDate. UpdatedDate is stored in string format e.g. 9/9/2022 9:55:16 PM
var collection1 = _collection
....
0
votes
0
answers
18
views
New user not being registered in mongodb from nodejs and express
I have developed an API using Node.js to facilitate user creation and management. Each user is granted the privilege to book visits to properties within the system. While user registration and ...
1
vote
1
answer
68
views
How to perform find operation for query with ObjectId in mongodb?
I have a database of sessions where I stored the active sessions of users.
this is a screenshot of the Session database:
now, as we can see the user_id is storing the ObjectId of users and I want to ...
0
votes
0
answers
25
views
MongoDB - Query Targeting: Scanned Objects / Returned has exceeded 1000
I'm receiving this MongoDB alert: Query Targeting: Scanned Objects / Returned has exceeded 1000.
Although I believe I've indexed the necessary fields for my query, it seems that the issue lies in the ...