mongodb-query Questions
6
Solved
I need to check if a find statement returns a non-empty query.
What I was doing was the following:
query = collection.find({"string": field})
if not query: #do something
Then I realized that my...
Longfaced asked 24/10, 2014 at 14:18
5
Solved
I've the following document in MongoDB...
{
"_id" : ObjectId("531221cd960100960116b992"),
"username : "joe",
"address" : [
{
"zip" : "8000",
"city" : "Zurich"
},
{
"zip" : "6900",
"city"...
Osanna asked 1/3, 2014 at 22:19
2
Solved
I'm connecting to a local MongoDB instance installed through brew via the IntelliJ Database tool.
I can see and query things; but as soon as I try to update a record eg set a database lock back to ...
Tamikatamiko asked 16/12, 2019 at 22:38
3
Solved
I use aggregation framework for group by of multiple fields as
{
_id:{_id:"$_id",feature_type:"$feature_type",feature_name:"$feature_name"},
features: { $push: "$features" }
}
it give result lik...
Rositaroskes asked 12/7, 2018 at 6:51
3
Solved
With a collection of documents with fields field1, field2, field3 and so on, I need to find
distinct values for field3
for each distinct value of field3, need to get the first document with each ...
Semiquaver asked 17/2, 2017 at 13:56
6
Solved
So as you all know, find() returns an array of results, with findOne() returning just a simply object.
With Angular, this makes a huge difference. Instead of going {{myresult[0].name}}, I can simp...
Kennith asked 8/6, 2016 at 1:2
20
Solved
Suppose you have the following documents in my collection:
{
"_id":ObjectId("562e7c594c12942f08fe4192"),
"shapes":[
{
"shape":"square",
"color":"blue"
},
{
"shape":"circle",
"color"...
Freitas asked 21/10, 2010 at 7:31
5
Solved
I am using mongoose to perform CRUD operation on MongoDB. This is how my schema looks.
var EmployeeSchema = new Schema({
name: String,
description: {
type: String,
default: 'No description'
...
Imogene asked 28/7, 2015 at 12:59
8
Solved
I am using pymongo to query for all items in a region (actually it is to query for all venues in a region on a map). I used db.command(SON()) before to search in a spherical region, which can retur...
Randirandie asked 10/3, 2015 at 16:10
2
Solved
Using the latest Spring Data Mongo (2.1.1 at time of writing), how do I specify to get the first record of a "custom" query method? Here is an example:
@Query(value="{name: ?0, appro...
Cordero asked 24/10, 2018 at 18:29
4
Solved
The data type of the field is String. I would like to find the length of the longest and shortest value for a field in mongoDB.
I have totally 500000 documents in my collection.
Ophir asked 16/10, 2014 at 2:46
12
Solved
I have a data like this in mongodb
{
"latitude" : "",
"longitude" : "",
"course" : "",
"battery" : "0",
"imei" : "0",
"altitude" : "F:3.82V",
"mcc" : "07",
"mnc" : "007B",
"lac" ...
Doucet asked 12/1, 2012 at 13:22
47
Solved
I want to query something with SQL's like query:
SELECT * FROM users WHERE name LIKE '%m%'
How can I achieve the same in MongoDB? I can't find an operator for like in the documentation.
Skill asked 22/7, 2010 at 3:19
5
Solved
I need to Update the Value of Profession_id from string to ObjectId for all document in a mongodb collection.
My Collection Profession is (Here I pasted only 2 Documents, in real I'm having more t...
Reinhart asked 9/6, 2016 at 6:4
16
Solved
I have a MongoDB collection with documents in the following format:
{
"_id" : ObjectId("4e8ae86d08101908e1000001"),
"name" : ["Name"],
"zipcode" : ["2223"]
}
{
"_id" : ObjectId("4e8ae86d081019...
Scranton asked 18/10, 2011 at 17:18
5
I have access logs such as below stored in a mongodb instance:
Time Service Latency
[27/08/2013:11:19:22 +0000] "POST Service A HTTP/1.1" 403
[27/08/2013:11:19:24 +0000] "POST Service B HTTP/1.1" ...
Lovelorn asked 28/8, 2013 at 9:49
2
Solved
I need to update a field of one element from array sub document of a document.
MongoDB have the $ positional operator to do this. But in MongoDB C# driver version 2 it seems that there is no suppo...
Meuse asked 22/2, 2017 at 16:19
4
Solved
I was working with the MongoDB Atlas Server...
and encountered this error...
What does it mean...?
Can someone explain in simple words plz...
This was the query i was trying...
db.posts.find({}, {t...
Hartzell asked 15/11, 2022 at 15:13
3
I want to create this partial index:
db.mycollection.createIndex(
{"firstname": 1, "lastname": 1},
{ partialFilterExpression: { "status": {$exists: false}, "quantity": { $lt: -1 } } } );
bu...
Pathy asked 13/6, 2020 at 22:41
2
With mongoDB 4, is there any feature to disable the auto creation of collections/dbs? We need to disable the auto creation of collections/dbs in our mongo cluster, so that only defined db and colle...
Reconvert asked 16/5, 2020 at 17:55
3
Solved
I'm trying to save the longitude/latitude of a location in my user Model and query it with $geoNear. I've looked at almost any page I could find on that topic, but still I'm not sure how to 1) crea...
Vasos asked 25/8, 2015 at 8:55
4
Hello I have a beginner question I suppose...
I've had a look around but could not find the answer
I have the following collection of users that I'd like to clean before I redefine my user model ...
Rhigolene asked 17/6, 2016 at 10:30
3
Solved
We have a simple application in which we have all user in same timezone & therefore we are not interested to store timezone information in mongo date object.
Reason for such extreme step is w...
Cambria asked 15/7, 2016 at 16:43
3
Solved
I have this little schema for users:
{
username: String,
contacts: Array
}
So for example some user's contacts will look like this:
{
username: "user",
contacts: [{'id': ObjectId('525.....e...
Convivial asked 8/10, 2014 at 8:40
12
Solved
Im trying to connect my mongoose with my MongoDB Atlas Cluster. It currently has no database or anything but whenever I try:
mongoose.connect( uri || 'mongodb://localhost/test',options)
.then(()=&...
Prodrome asked 14/5, 2020 at 14:35
© 2022 - 2024 — McMap. All rights reserved.