I discovered one of my mongodb documents has duplicate fields with the same key.
I also realize this is supported by mongoDB (as per MongoDB Documentation)
I'm wondering if anyone knows how to properly query to diagnose the scope of such an issue.
And if anyone has any insight into possible root causes when working in Javascript that'd be nice too.
Related
I would like to know if in Mongo it is possible to create an index on embedded fields without using dot notation and how to do it. Our client is asking for this other option but we can't find any reference in the official documentation (unless we are mistaken).
Has anyone done it before? Any advice on this topic?
Thank you very much,
Irene.
For the last week and a half for some reason my Mongodb collections all get dumped. I can't find a reason why this is happening there doesn't seem to be a real pattern to when/why the collections get dumped. Does anyone have any insight? I'm running Mongodb version 2.6.12.
you can read this artical https://snyk.io/blog/mongodb-hack-and-secure-defaults/
also you can have a look on MongoDB database deleted automatically it should solve your problem.
How can I determine what collection a Mongo document belongs to?
I'm using MeteorJS, but even if you don't use this, I'm pretty sure I have access to MongoDB's internal commands so please answer anyways.
Happy to close if this is a duplicate, but I didn't find anything close to this.
There isn't a real short command but to cycle through each collection and query for the field, or fields that uniquely identifies this document. Don't know MeteorJS but if you are looking for just a quick way to get the data to find out and not add a program function you can download RoboMongo. Think of it as SQL Management Studio for MongoDB. If you are looking for a program function to do this then I suggest you make it a jscript function you create inside MongoDB (similar to stored procedures) to do the work and return the results to you when done.
Are you querying the document now and wondering where it is coming from? If so, it should be in the code.
I'm following the doctrine extension installation guide to set up slugs in mongodb documents. I'm able to do that without any problem. However, it does NOT seem to work on embedded documents. It simply does not populate the specified slug field. No error is thrown.
I'm just curious has anybody been able to generate slugs on mongodb's embedded document? If so, is there any additional settings that I need to specify? Thanks!
Turns out it wasn't the problem with DoctrineExtension. I was trying to persist the embedded document when I should be persisting the parent document. Therefore, the embedded document was never saved.
Bear with me as I'm pretty new to MongoDB and mongoose has been my only interaction with it. So apologize ahead of time if I'm not properly separating the two technologies or understanding either.
I have a collection that is basically a log. Each log item is the result of a status check on a specific server that I have in my system. When I delete a server I'd like to also remove all the associated log entries. Whats the most efficient way to do this? I know I can find all the log items with a specific server id then iterate through each and remove it but that seems really inefficient. I've read through most of the mongo documentation and it looks like findAndModify is the best way to do this but I can't figure out syntax for this with mongoose. Any chance someone could help me out?
I'm using the latest version on mongoose at the moment, 1.7.2
Maybe I'm missing something here, but why not just do
db.logs.remove({serverid: deletedServerId})
?