[英]export to csv mongodb collection using mongoexport
我正在嘗試使用mongodbexport從mongoDB的集合中導出所有數據。 我遵循以下語法:
mongoexport --db mydb --collection mycollection --csv --out text.csv --fields NameColumn1,NameColumn2,NameColumn3等...
運行上面的代碼,它將僅創建一個帶有字段名且沒有值的文件。 如果僅刪除--csv並將其更改為text.txt,它將導出所有數據。
我還有其他參數嗎?
我是對的,問題出在Guid物業。 我更改為字符串,現在可以正常工作了。 我會詳細說明這個問題,因為它可以幫助其他人。
我在我的項目中使用的是MongoDB C#官方驅動程序。 我是通過Nuget安裝的,當前版本是1.8.0。
這是我以前保存的代碼:
public void Save(SampleModel model)
{
var collection = _database.GetCollection<SampleModel>("SampleCollection");
collection.Insert(model);
}
此樣本模型具有以下屬性:
public Guid MyId { get; set; }
public DateTime InitProcess { get; set; }
public DateTime EndProcess { get; set; }
public string RuleName { get; set; }
public bool Match { get; set; }
public DateTime InitUpdate { get; set; }
public DateTime EndUpdate { get; set; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.