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,488
questions
-1
votes
0
answers
15
views
I've been trying to apply unique index in combination in mongoDb databse using in my node.js backend, but unable to get away with the duplicate error
The movie is supposed to be added to the single document named as watchlist of all user, but i tried to apply unique index in combination of profile_id(user) and content_id(movie_id) so that same ...
0
votes
1
answer
21
views
Add a field inside an array within a MongoDB object, with values computed dynamically based on other values inside the same nested array
I have a simple MongoDB array of objects with this structure:
[
{
"_id": {
"$oid": "6688c2f6b79f2bfefb751d5f"
},
"date": "06/07/2024&...
0
votes
0
answers
18
views
Mongo DB Atlas | Aggregation not getting response
Am doing a personal project and using MongoDB Atlas for storing documents. I have the below code
app.get('/admin/dashboard', (req, res) => {
console.log('Received request for admin ...
1
vote
1
answer
33
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
21
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
70
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
46
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
54
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
26
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
23
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
31
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
9
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 ...