mongodb-query Questions

7

Solved

I'm just trying to get a simple near query working. Here's a sample of my document. {"point": {"type": "Point", "coordinates": [30.443902444762696, -84.27326978424058]}, "created_on": {"$dat...
Totaquine asked 20/4, 2014 at 23:51

4

Solved

I'm trying to query a collection using operands AND'd together. I've got the shell version working: db.widgets.find({color: 'black, shape: 'round', weight: 100}) I'm unable to find the Java equi...
Folkway asked 22/6, 2014 at 17:3

2

Solved

According to the mongodb node driver docs the aggregate function now returns a cursor (from 2.6). I hoped that I could use this to get a count of items pre limit & skipping but there doesn't s...
Burtie asked 11/8, 2014 at 8:58

8

Solved

2 days old with Mongo and I have a SQL background so bear with me. As with mysql, it is very convenient to be in the MySQL command line and output the results of a query to a file on the machine. I...
Taitaichung asked 21/3, 2014 at 17:12

5

Solved

I'm trying to group a set of documents and count them based on their value: { item: "abc1", value: 1 } { item: "abc1", value: 1 } { item: "abc1", value: 11 } { item: &...
Godliman asked 11/5, 2015 at 13:35

5

Solved

I have a group of statuses of pretend payments, each with a payment ID. I want to get the latest status for each payment ID. The test I have creates some dummy data and then tried to query it. I'v...

1

I am developing an spring boot application connected to a mongo db database. I dont know why but sometimes is giving me the following error: org.springframework.data.mongodb.MongoTransactionExcepti...
Coppock asked 1/7, 2021 at 11:21

5

Solved

How does one use Mongo Compass and search by ObjectID? I've been searching for the documentation for this but haven't been successful with anything. I have tried: { "_id" : "58f8085d...
Zinazinah asked 20/4, 2017 at 16:54

5

Solved

I have documents that looks something like that, with a unique index on bars.name: { name: 'foo', bars: [ { name: 'qux', somefield: 1 } ] } . I want to either update the sub-document where { name...
Epstein asked 5/5, 2014 at 10:49

6

Solved

Is there a way to convert string to date using custom format using mongodb shell I am trying to convert "21/May/2012:16:35:33 -0400" to date, Is there a way to pass DateFormatter or something to ...
Zerline asked 8/6, 2012 at 4:5

5

Solved

I have store two field FirstName and LastName stored in MongoDB.from Frontend, I am receiving a string containing both first name and last name separated by space I need a find query which searches...
Spartan asked 18/9, 2019 at 7:18

4

Solved

I am trying to fetch data based on some match condition. First I've tried this: Here ending_date is full date format Offer.aggregate([ { $match: { carer_id : req.params.carer_id, status : ...
Betz asked 17/11, 2015 at 9:2

3

I have not find a method to do it yet. If we can not remove documents using regex expression, what can we do to make it done? And why does not mongodb provide such a driver ?
Anthocyanin asked 17/7, 2014 at 7:31

8

Solved

What's the syntax for doing a $lookup on a field that is an array of ObjectIds rather than just a single ObjectId? Example Order Document: { _id: ObjectId("..."), products: [ ObjectId("..<C...
Pillbox asked 23/1, 2016 at 18:58

10

Solved

Is there a query for calculating how many distinct values a field contains in DB. f.e I have a field for country and there are 8 types of country values (spain, england, france, etc...) If someon...
Medusa asked 17/2, 2013 at 18:27

3

I would like to retrieve a sub document from a document in MongoDB. I have the following document: { "_id" : "10000", "password" : "password1", "name" : "customer1", "enabled" : true, "channe...
Shofar asked 14/1, 2014 at 12:25

4

Solved

I have a problem when querying mongoDB with nested objects notation: db.messages.find( { headers : { From: "[email protected]" } } ).count() 0 db.messages.find( { 'headers.From': "[email&#160...
Malpractice asked 14/4, 2013 at 18:21

4

Solved

I would like to make a search on a collection in my mongodb database. In my collection, I have documents with the field "name" can be values like: [i] "Palácio Guanabara", "Palácio da Cidade", "Fe...
Tachylyte asked 15/4, 2016 at 12:31

2

Solved

For background, if I want to compare two fields, I can't use the following syntax (because it compares to the literal string "$lastName" rather than the contents of the $lastName field): "$match":...
Rubierubiginous asked 12/7, 2018 at 17:13

6

Solved

I have two keys A and B and their existence in the document is mutually exclusive. I have to group by A when A exists and group by B when B exists. So I am $projecting the required value into a com...
Hazlett asked 8/1, 2013 at 11:8

5

Solved

Here's my MongoDB collection: { "_id" : ObjectId("515d8f53175b8ecb053425c2"), "category" : "Batteries", "products" : [ { "brand" : "Duracell", "item" : [ "AA", "AAA" ] }, { "brand" : "...
Debor asked 4/4, 2013 at 14:46

4

Solved

I want to use $or and $regex operators same time. db.users.insert([{name: "Alice"}, {name: "Bob"}, {name: "Carol"}, {name: "Dan"}, {name: "Dave"}]) Using $regex works fine: > db.users.find...
Glottis asked 7/8, 2014 at 8:27

4

Solved

I am trying to add a new field to a document, but this isn't working: Creating my UserModel prototype: model = require("../models/user") UserModel.prototype.findOneAndUpdate = function(qu...
Collinsia asked 19/6, 2018 at 18:28

1

I am using Mongodb Atlas and need to get the last 10 records. For which, have to apply a filter having sort and limit options. In mongo shell, we do it in this way: db.category.find().sort( { name:...
Nerte asked 7/10, 2020 at 6:36

2

Solved

I'm Strugling with some aggregation functions in mongodb. I want to get books Documents in author's document that has just books ids as array of strings ids like this : Author Document { "_id" :...
Scalp asked 28/6, 2017 at 7:35

© 2022 - 2024 — McMap. All rights reserved.