mongoexport

How can I work with “join” to export data from MongoDB?

旧时模样 提交于 2019-12-05 21:37:15
I have 2 collections: list1 and list2. list1 have some fields and list2 have another fields, including the id referring to list1. I need to do a query to export all items on list1 that have at least one item referring to him on list2. How can I do this? It's something like a join from list1 to list2. I need to run a mongoexport command to generate a csv file. The way I do this is to create a short javascript program that will transfer the data you want to export into a new temporary collection, which you can then export. For example, create a file export.js: //initialise the export results

mongoimport 2.6 vs 2.4

戏子无情 提交于 2019-12-04 10:26:37
I am exporting data from one database and importing data to another database. When I export the data its on a machine with mongo 2.6 but when I import the data its on a VM using mongo 2.4. Both mongod instances are running 2.4. I keep getting this error: Wed Jun 4 13:13:32.604 check 0 0 Wed Jun 4 13:13:32.604 imported 0 objects Wed Jun 4 13:13:32.604 ERROR: encountered 1 error(s) failed: [192.168.140.30] => (item=collection) => {"changed": true, "cmd": "mongoimport -u username -p password -d db -c collection --drop --jsonArray /tmp/collection.json ", "delta": "0:00:00.026383", "end": "2014-06

MongoExport Too many positional options

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Am trying to run a mongoexport using a remote connection by filtering on date ranges. A very simple query, however, I am running into positional errors issue. I;ve read through most of the posts regarding it, did the epoch conversion etc. But completely hit a block. Hopefully someone here can figure out what I am doing wrong. Below is my command and the error message: C:\ mongoexport --host 1.1.1.111:1111 --db IQ -u user -p password --collection CallLog --out calllog.json --query '{"Call.StartTime":{"$gte":new Date(1411066005000),"$lte": new

数据库导入导出和备份恢复

匿名 (未验证) 提交于 2019-12-02 23:34:01
需要注意的地方: 1,不需要进入mongo命令行之后,就可以直接使用上面的2个导入导出命令。 2,导入导出的json文件,你不要随意换行,导出来的就是一行一条数据,你就原封不动的给修改完直接保存,不要换行。不要使用txt这么low的编辑器啦,换个高级点的编辑器吧。 更多内容请致官方地址:https://docs.mongodb.com/v2.2/reference/mongoexport/ 导出:mongoexport 1、语法: mongoexport -d dbname -c collectionname -o file --type json/csv -f field 参数说明: 2、示例: sudo mongoexport -d mongotest -c users -o /home/python/Desktop/mongoDB/users.json --type json -f "_id,user_id,user_name,age,status" 导入:mongoimport 1、语法: mongoimport - d dbname - c collectionname - - file filename - - headerline - - type json/csv - f field 参数说明: 2、示例: sudo mongoimport -d mongotest

mongoexport aggregate export to a csv file

ε祈祈猫儿з 提交于 2019-12-02 19:56:31
I want to save the result from an aggregation into a csv file. Using the mongo cmd line tool I can do this to get the results I want: db.compras.aggregate({ $group : { _id : "$data.proponente", total : { $sum : "$price" } }} How would I translate this into a mongoexport command that saves results into a csv? You can't run aggregate() queries through mongoexport . The mongoexport tool is intended for more basic data export with a query filter rather than full aggregation and data processing. You could easily write a short script using your favourite language driver for MongoDB, though. Slightly

Which MongoDB types are not preserved by mongoimport/mongoexport?

若如初见. 提交于 2019-12-01 11:52:16
问题 The documentation for mongoexport has this scary warning, Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as described in MongoDB Backup Methods for this kind of functionality. The page then goes on to say, To preserve type information, mongoexport and mongoimport uses the strict mode representation for

mongodb: extract timestamp from ObjectID in json query

荒凉一梦 提交于 2019-11-30 22:16:22
I want to extract the timestamp from my ObjectID with a json query, as I would like to use mongodump but only dump data between certain dates. I dont wanna put my timestamps somewhere else than the ObjectID as I need the database to be as small as possible. Is there a way to to exstract the timestamp from ObjectID with a simple json query that mongodump accepts? You can do this fairly simply, at doc page Mongo Extended JSON (which is quite well hidden) you can find a table describing how to represent mongo extended datatypes in JSON. As you probably know, the first 4 bytes of ObjectId

mongoexport syntax error message

纵然是瞬间 提交于 2019-11-30 15:08:40
问题 I'm working with mongodb 2.4.3 and I cannot get mongoexport to work. The error message I get with each command is: "JavaScript execution failed: SyntaxError: Unexpected identifier" At first I thought the problem was with my query parameters, which were long. But find() worked fine with the query so I know that the syntax is ok. I then created a new collection using the query and tried exporting the collection with the following: mongoexport --db Oct2012 --collection sept8subset --csv --fields

mongoexport syntax error message

别说谁变了你拦得住时间么 提交于 2019-11-30 13:28:44
I'm working with mongodb 2.4.3 and I cannot get mongoexport to work. The error message I get with each command is: "JavaScript execution failed: SyntaxError: Unexpected identifier" At first I thought the problem was with my query parameters, which were long. But find() worked fine with the query so I know that the syntax is ok. I then created a new collection using the query and tried exporting the collection with the following: mongoexport --db Oct2012 --collection sept8subset --csv --fields "text","created_at","user.screen_name","user.followers_count" --out sept8.csv mongoexport --db Oct2012

MongoDB 数据导入导出问题

江枫思渺然 提交于 2019-11-30 01:57:06
MongoDB 数据导入导出问题 一、Mongodb导出工具mongoexport mongoexport具体用法 mongoimport具体用法 导出数据命令: 主意 一、Mongodb导出工具mongoexport Mongodb中的mongoexport工具可以把一个collection导出成JSON格式或CSV格式的文件。可以通过参数指定导出的数据项,也可以根据指定的条件导出数据。 mongoexport具体用法 1、导出数据命令: mongoexport -h [host] --port [port] --u [username] --password [password] --authenticationDatabase admin -d [databsename] -c [collectionname] -o [outputfilename] -q {query} 参数说明:     -h : host名     --port : mongo运行端口     -u: mongo用户名     -p:mongo密码     -d :数据库名      -c :collection名      -o :输出的文件名      --type : 输出的格式,默认为json(获取–csv导出csv格式文件)      -f :输出的字段,如果-type为csv,则需要加上-f