Before Mongo 3.2 which method was used to find - mongodb

I have an installation of Mongo v3.0.15 and I cannot execute the find command from my application. I need to build this with backward compatibility, so, which command was used instead of find for previous versions of Mongo 3.2?
The current error that I receive from Mongo is:
find command not yet implemented
mongo driver: gopkg.in/mgo.v2
Then am trying to retrieve records using:
s.session.DB("").Run(rawQuery, &queryResult)

Related

mongosh: how to connect with uuidRepresentation=javaLegacy?

I am connecting to my local host mongodb via moongo shell with the following command and getting the following error.
Command
mongosh "mongodb://username:password#localhost:27017/authDb?uuidRepresentation=javaLegacy"
Error
Connecting to: mongodb://<credentials>#localhost:27017/authDb?uuidRepresentation=javaLegacy&directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.2.3
MongoParseError: option uuidrepresentation is not supported
My requirement is to execute mongo queries that involves Java Legacy UUIDs and the expect the query results to be represented like that.
I can achieve this via tools like Robo3T though.
But I am a specific case where I must do it via mongo shell.
I cannot find any support for this elsewhere.

How do you convert mongod to mongo service?

I have been running MongoDB on two Windows 10 PCs. However, one has mongo always running it seems where I only need to open command prompt and type mongo. This gives me access to the db on PC #1.
However, on PC #2, I must open command prompt and type mongod. Then I have to open a second command prompt to type in mongo, then I get access to the db on PC #2.
After doing this for about a year, I find I want to just want both PCs to work like PC #1, where I just type in mongo and not mongodb and only have to use one command prompt.
I checked online but there's nothing I found straightforward to accomplish this specifically.
Does anybody know the answer?
If in PC#2, your MongoDB version is < 4.0, then you can't do anything i.e., you have to continue with mongod to start Mongo as you do now.
But if your MongoDB version is >= 4.0 or you want to upgrade from lower version of MongoDB, you can follow the below steps.
Take backup of all databases with mongodump. If it is large volume data, then go through this.
Uninstall your MongoDB using Windows Uninstall Program features.
Reinstall MongoDB using the link.
While installing, ensure you select 'MongoDB Service' feature.
Start the MongoDB now in PC#2 as you do in PC#1.
Restore the old databases with mongorestore.

mongodb 3.2.11, version too new for this mongod

I have an issue with mongodb server. I am using version 3.2.11.
Unable to find metadata for table:index-3--5957523542490303670 Index: {name: id, ns: dashboard.dataaas} - version too new for this mongod
I have already update mongo version to 3.4, but it still could not start the server on, the error still remains.
I would like to delete that index / table, but I could not log in to mongo-shell. And could not found file index-3--5957523542490303670 in any of folder
Please help
Basically as error states, mongo client/shell as well as mongod server should have the same version. You can check the mongo shell version using mongo --version. If it does not match, downgrade/upgrade client as required.
Also check if server is running.

mongodb - command 'show collection' doesn't show anything

I switched my db properly and also confirmed that there is a document in my collection but I cannot find any collection by 'show collection' command.
Can I know the reason?
Please check your Mongo shell version and MongoDB version are compatible.
Refer to this JIRA ticket which has the similar issue reported. The root cause of the problem was the Mongo shell version and MongoDB version were not compatible.
To get Mongo Shell version:-
Go to the bin folder and execute mongo command which will print the Mongo shell version in the first line.
To get MongoDB version:-
db.version()

How to copy database from MongoDB 1.6 instance

I have a MongoDB instance with two databases, let's call them "realdb" and "copydb".
All I want to do is to periodically copy realdb to copydb. The copydb database is our "testing" instance of the actual database "realdb", and we want to periodically update it.
Normally the answer to this question would be "copydb" or "export/import". However, there are some challenges:
The target Mongo instance is running version 1.6 and is not likely to be updated anytime soon.
The target Mongo instance is on a remote server to which I don't have direct access.
This seems like basic enough a function that even 1.6 should have the ability to do it. But when I try anything I get "No such cmd" errors as if the newer Mongo can't communicate with the ancient Mongo.
Any thoughts on how this could be done?
The error "no such command" might mean that:
The command was mistyped, or does not exist
There is a mismatch of the client version (e.g. mongo shell, mongodump, mongoexport, or a mongodb driver) and the server version.
In this case it was a mismatch of the mongo shell version (3.4) vs server version (1.6).