我想从集合中导出第一个1-100000条记录。
我知道我可以输入> db.mycollection.find({}).limit(1000000)
,但它只是获取数据,需要将数据导出为json文件。
示例数据
> db.minibars.find({}).limit(3)
{ "_id" : ObjectId("575fd03f6a6253c0b30dd54c"), "Symbol" : "MSFT", "Timestamp" : "2009-08-24 09:30", "Day" : 24, "Open" : 24.41, "High" : 24.42, "Low" : 24.31, "Close" : 24.31, "Volume" : 683713 }
{ "_id" : ObjectId("575fd0406a6253c0b30dd54d"), "Symbol" : "MSFT", "Timestamp" : "2009-08-24 09:31", "Day" : 24, "Open" : 24.32, "High" : 24.33, "Low" : 24.28, "Close" : 24.3, "Volume" : 207651 }
{ "_id" : ObjectId("575fd0406a6253c0b30dd54e"), "Symbol" : "MSFT", "Timestamp" : "2009-08-24 09:32", "Day" : 24, "Open" : 24.29, "High" : 24.33, "Low" : 24.29, "Close" : 24.31, "Volume" : 230729 }
我该怎么做?
答案 0 :(得分:2)
请查看此处的文档:https://docs.mongodb.com/manual/reference/program/mongoexport/
您正在寻找public class ExpenseDetailDTO {
String description;
Long amount;
@DateTimeFormat(pattern = "yyyy-MM-dd")
Date created;
@DateTimeFormat(pattern = "yyyy-MM-dd")
Date updated;
....
}
示例:
mongoexport