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
Related
Please help, been stuck for hours, how do I delete a document that matches a query directly in pymodm.
For example:
user = User.objects.raw({'name':'Moses'})
How do I delete this user from my database collection?
you can use the delete() method to delete document from the MongoDB, try the below code this worked for me fine.
user = User.objects.raw({'name':'Moses'})
user.delete()
I have tried to get the last saved documentId from the mongo database. But whatever I try I don't get anything back.
Can someone please hint me how to solve this in C# i have tried doing the sorts and take the last document but i don't get anything back.
MongoDB does not have such an operation.
If you want to know the id of inserted document, generate the id on the client side before inserting.
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
I am not able to delete a document from MongoDB using Mongo Express when it has _id equal to NaN.
After pressing BIN button it says:
Document not found!
Any ideas how to manage it from Mongo Express?
Considering that the url and dateUpsertFromFile is not empty, I believe that the document do exist in the database. Perhaps incorrect data binding? You can do db.collection.remove({url: "Vista Room Near BBC Towers...<complete the url>"}) to delete it instead, but my previous point stands. You should be able to find the _id somewhere.
Is there any way to find last update Document in Collection? in other way sort collection by update
somethings like this
people = Person.objects.order_by_update()
or i must add update time for each doc?
I use mongodb, mongoengine, flask
You must add a field such as last_updated_time if you want to be able to sort in this way. Also, since you're sorting on it, you should probably index it.
The only thing that mongodb stores by default is _id, which can be used roughly as a created_time timestamp.