Cannot update a document - mongodb

I am facing some problems trying to update a document. It is a simple update command but it didn't save any changes. So. I am looking for some advice.
This is the query:
db.Customers_DEV.update(
{"fn": "QA_Isabel10K"},
{
$set: {
"db" : ISODate("1988-08-17T06:00:00.000Z")
}
});
The document does exist and it throws the next message as a result:
Updated 0 record(s) in 50ms
Also tried by right clicking on the document and "Edit Document..." but here it throws the following error:
Error when saving document: 1 Not primary while performing update on [database].
I am using Robomongo 0.9.0-RC10
Thanks in advance
UPDATE
This is the document:
Document to modify

Solved. Posting here for future reference.
I am not pretty sure how mongodb/robomongo works but the problem was the port number on my connection string. It unable me to make any insert nor update on the database.
Thanks and hope this help somebody else.

for me, it helped to update Robo3T from 1.4 to 1.4.4

Related

Adding condition on a date field in PDI

I am using PDI to extract data from the database. I am having a problem where i cannot add a condition in date field as it always gives error.
I have tried following ways
{news_date: {$gte: ISODate("2020-12-30")} }
{news_date: {$gte: new Date("2020-12-30")} }
nothing is working and I am always getting errors. Any help in this regard will be much appreciated. How do I pull data from mongo DB filtered on Date?
following is the error i am getting on preview which also makes no sense to me
This works for me:
{ news_date: { $gte: ISODate("2020-12-30T00:00:00.000Z")} }
But how the stored news_date looks like?

How to insert the data into mongoDB collection manually

I want to insert the data into Robo3T manually. I tried using insert and insertMany command, but nothing works for me. Please provide me the solution if it's possible.
db.getCollection('YourCollectionName').insert({"name" : "ABC"})

Why does my update $set code remove my entire document?

Help!
I don't what am doing wrong, when I try to update an existing field using the $set method the entire document gets removed.
Can you kindly point out what I am doing wrong in my code:
recipientsDetails.update({_id: "GCYmFqZbaaYD7DvMZ"}, {$set: {paymentStatus: "Approved"}});
Thanks for your help!
The code is correct. It's likely that your publish function for recipientsDetails contains recipientsDetails.find({paymentStatus: "Not Approved"}). Naturally, once you update the document, the document will no longer satisfy that filtering query and the document vanish from the client.
Your code is correct.Check you mongoDB using Robomongo tool.connect your local project with robomongo and update a document then check whether it is updated or not? If the record updated there is an issue with the publish or subscriptions

meteor remove a record is not updating in the mongo server

var fanclub;
fanclub = Fanclub.findOne({"name" : e.target.value});
console.log(Fanclub.find().count());
Fanclub.remove({
_id: fanclub._id
});
console.log(Fanclub.find().count());
I am trying to remove a record but always showing the one count less when I remove record but it is not updating the mongo db.
I have tried to use publish method but its not working. Can you please help in this

MongoDB - mongohub gui - queries by _id objectid type

I am using MongoHub GUI for MongoDB: http://mongohub.todayclose.com/
I would like to be able to query by ObjectId as this is what MongoHub is returing for _id. How to do this, something like {"_id":"4d1b4687a6d5437619000000"} is not working??
cheers,
/Marcin
try following code:
{"_id": ObjectId("4d1b4687a6d5437619000000")}
check this for more details
It looks as if MongoHub is broken in the case of supplying a function in a query (ObjectId, as galimy rightly suggested). If you enter the query as galimy suggested, then copy and paste the full query that MongoHub says it's going to execute (grayed out above the Query text input) into a connected mongo CLI console, it works fine.
I would recommend learning to use the mongo console -- I've found two bugs in 5 minutes of playing with MongoHub, and when you're typing in JSON for your queries anyway the GUI is doing very little for you.
OK, it has been fixed in recent MongoHub release. Cheers
{"_id": { $oid: "4d1b4687a6d5437619000000"}} definitely should work. Java MongoDB driver implicitly creates ObjectId object in the object has '$oid' property.
Also all the same is for date using '$date' property.