Rectangle 27 0

Database References (aka DBRefs) are only a notational data convention in MongoDB and do not (as at MongoDB 2.4) have any special server-side support for populating the references.

Many application drivers or frameworks have support for working with DBRefs, but do so by generating additional queries to get the referenced documents.

If you want to populate DBRefs when exporting data, you will have to write your own export script.

mongodb and a "deep" mongoexport - Stack Overflow

mongodb mongoexport
Rectangle 27 0

It appears that you have a database called ds:

> use ds
switched to db ds

use ds switches the current database to the ds database (db from the shell is just an alias for the current database).

Then, you have a collection called ds as well:

> db.ds.find().pretty()

So, that means you have a ds database with a ds collection (ds.ds).

You should then use the export like this with the --db option set to ds (assuming the path to the database is correct):

mongoexport --db ds --collection ds --dbpath ~/db --out ds.json
--dbpath

it doesn't work for me, i still have the same msg "exported 0 records"

@Tmp mongoexpert is not to type in mongoshell. It should be type in bash. so if you give --out (or - o ) with only file name, it'll be create where your terminal is (pwd = present working directory)

mongodb - mongoexport does not write any records to json output file -...

mongodb mongoexport
Rectangle 27 0

For some reason no matter what i did, mongoexport or mongodump utilities didnt work for me as the default user, even after resetting my password, whilst I was, however, able to connect as default user to the mongo shell.

But the solution for me was from the settings page of your database on mlabs.com you can create more users, and i was then able to connect to these utilities with the new user. You can probably create new users in the shell too, but id just use the online tool.

mongoexport -h <serverURL:port> -d <database> -c <collection> -u <newuser> -p <newpassword> -o collection.json

MongoDB - can't get data exported with mongoexport due to auth failed ...

mongodb mongoexport
Rectangle 27 0

Database References (aka DBRefs) are only a notational data convention in MongoDB and do not (as at MongoDB 2.4) have any special server-side support for populating the references.

Many application drivers or frameworks have support for working with DBRefs, but do so by generating additional queries to get the referenced documents.

If you want to populate DBRefs when exporting data, you will have to write your own export script.

mongodb and a "deep" mongoexport - Stack Overflow

mongodb mongoexport
Rectangle 27 0

The answer given by GianPaJ is the solution I'm using, however a shortcoming is that it is only outputting the exported data to the remote host, not to your client.

One work around is to use SCP or SFTP on the exported file. I will update this post if I figure out how to actually transfer that file with a mongoexport option.

mongoexport --host {host} -f {fields} -d {db} - c {coll} --csv -o {absolute_local_path}

mongodb - I need to call mongoexport remotely and get the result from ...

node.js mongodb csv remote-server
Rectangle 27 0

mongoexport -h kahana.mongohq.com:12345 -u username -p password -d my_db -c usercollection -f "firstName,lastName,macIdNum,iclass" --csv

The '-h' hostname option is meant to specify only 'hostname/IP:port'.

mongodb - Mongoexport remote database not connecting - Stack Overflow

mongodb csv mongohq mongoexport
Rectangle 27 0

You will have to open the MongoDB port and connect form the node server. Then use

mongoexport --username user --password pass --host host --db database --collection coll --csv

If it's in a public network make you use authentication.

Otherwise might be simpler to run an ssh command, run mongoexport on the MongoDb server and then sftp back the file (maybe zip it first).

Thats definately right way to go. I'm getting an "authentication failed" error when I try logging in. My user doesn't have a password so I left that field blank in mongoexport. I do use a private key to ssh into these servers, would that need to come into play here?

you can specify the sshkey on ssh -i identity_file but that's another topic

it seems to run without setting the username or pass

mongodb - I need to call mongoexport remotely and get the result from ...

node.js mongodb csv remote-server
Rectangle 27 0

It appears that you have a database called ds:

> use ds
switched to db ds

use ds switches the current database to the ds database (db from the shell is just an alias for the current database).

Then, you have a collection called ds as well:

> db.ds.find().pretty()

So, that means you have a ds database with a ds collection (ds.ds).

You should then use the export like this with the --db option set to ds (assuming the path to the database is correct):

mongoexport --db ds --collection ds --dbpath ~/db --out ds.json

it doesn't work for me, i still have the same msg "exported 0 records"

mongodb - mongoexport does not write any records to json output file -...

mongodb mongoexport
Rectangle 27 0

mongoexport -d db_dev -c users -f apiKey,email -q "{email:/@company.com/}" --csv -o /Users/kingHenry/Desktop/usersKeys.csv
connected to: 127.0.0.1
exported 205 records

mongodb - mongoexport with a query does not return expected results - ...

mongodb csv mongoexport