[SERVER-12624] Support writing to (bson) files from shell Created: 05/Feb/14  Updated: 27/Oct/21  Resolved: 27/Oct/21

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Michael O'Brien Assignee: Geert Bosch
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-14881 Ability to easily save cursor content... Backlog
Related
related to SERVER-14880 Ability to output to file from mongo ... Backlog
is related to SERVER-5447 Option to write shell commands and re... Closed
Participants:

 Description   

running mongodump with the correct args and dealing with extended json (shell escaping, quotes and $ characters etc) is very confusing and difficult.

it would be nice to just be able to run a query through the same shell mechanism and save it to a file.

Something like:

db.collection.find({created_at:{$lt:ISODate("2014-01-01T16:20:49.177Z")}).sort({created_at:1}).dump("/tmp/path_to_file.bson")

or if not part of cursor prototype, at least a shell helper to take a cursor and iterate it + write bson to local file on disk.



 Comments   
Comment by Geert Bosch [ 27/Oct/21 ]

In the mongo shell, there is a writeFile method.

Generated at Thu Feb 08 03:29:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.