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
1
vote
1
answer
35
views
MongoDB query for points with cutout
In my lootPoint collection I have the data like this:
{
"_id" : "1856132932",
"point" : {
"type" : "Point",
"coordinates&...
0
votes
0
answers
22
views
Mongodb query doesn't post or put data in deploy
I'm developing a simple forum website. It has a react frontend + node backend, with mongodb cloud as database and AWS Cognito for signup/ verification/ sign in. When a user signs up: 1. create a user ...
1
vote
3
answers
46
views
How to convert a positive integer to binary inside mongoDB aggregation
I was looking for a way to convert a positive integer into a binary array inside a mongoDB aggregation pipeline.
There is $bit operation which can't be used inside an aggregation pipeline.
This ...
0
votes
0
answers
31
views
Problems with my query in the json validator
[
{
$addFields: {
Larva: { $toInt: "$Larva" },
Ninfa: { $toInt: "$Ninfa" },
Pupa: { $toInt: "$Pupa" },
}
},
{
$group: {
...
1
vote
1
answer
71
views
How to write an efficient mongo query for complex structures
I am using express/nodejs(without mongoose) and mongodb as my database. I have a collection Pages which looks something like this
{
_id: ..
Urls: [
{
IncomingUrl: "/test/test1",...
2
votes
1
answer
48
views
How to exclude number in MongoDB filter $gte and $lte
I have a MongoDB document with number field:
[
{
_id: 1,
number: 10
},
{
_id: 2,
number: 11
},
{
_id: 3,
number: 12
}
]
And I'm using MongoDB filter $gte and $lte ...
1
vote
2
answers
55
views
MongoDB update single primitive in an array
I needed to run a quick and (I thought) trivial query to update some incorrect data. I'm trying to update the very first entry of an array in a document.
Note: My posted queries run against db ...
1
vote
0
answers
27
views
Is `{ field: { $in: [null, 'something-1', 'someting-2', []] } }` performance wise okay to use than separate query?
Query 1 : { field: { $in: [null, 'something-1', 'someting-2', []] } }
Query 2 :
{
$or: [
{ field: { exists: false } },
{ field: { $in: ['something-1', 'something-2'] } },
{ ...
0
votes
0
answers
45
views
MongoDB: Filter array field based on entry from the same array
Given the following collection
db.playground.insertMany([
{ "id": 1, "tags": [{"t": "T1", "v": "t11", "c": 1 }, {"t": &...
0
votes
0
answers
24
views
Getting Values in 15 Min Invervalls with MongoDB Aggregatio
I do have a MongoDB collection that stores values from some Airflow sensor. For putting these values into a line chart, I need these values grouped together into 15 minute intervals. My aggregation ...
0
votes
0
answers
32
views
Want to extract specific column and fetch count based on the condition
I have below documents in Mongo DB:
{_id
666b07c615b7246
host
"SERVER1"
ip_address
"10.0.0.1"
status
"Running"
timestamp
2024-06-13-01-00-10}
{_id
666b07c615b7246
host
&...
0
votes
0
answers
10
views
Saving limited records per TestCase name in Mongodb
I am working on a framework to save test data for QA test cases in mongodb. I want to save only 20 test data per api request. e.g. if api call is for member summary then I want to limit saving only 20 ...
0
votes
0
answers
19
views
CSV mongoimiport with merge option not updating existing data
I have an requirement to update existing mongo db document after reading some relevant data from hdfs saved as csv
Steps I am taking care of
Created a view on mongo collection to convert _id to it ...
0
votes
2
answers
46
views
MongoDB Index for sorting by Date
I have a simple question - maybe too simple so that I don't find an answer:
My collection has documents containing a field startTimestamp of type date. The UI shows the documents in descending order ...
0
votes
1
answer
48
views
MongoDB query with $sort takes too long
I have a large mongo collection, when I run {"$and":[{"fieldCheck":"1"},{"timestamp":{"$lt": MAX_SAFE_INTEGER}}]}, the query results the output fast, ...