我正在嘗試使用 mongo 創建一個新資料庫。(不是當前資料庫中的集合,如使用 "newDBname" 的結果)有誰知道怎么做?
c# 中的示例將不勝感激。
祝你有美好的一天
uj5u.com熱心網友回復:
根據doc,沒有這樣的顯式操作/查詢,如果之前沒有創建資料庫,當您第一次查詢它時,將隱式創建資料庫。在 C# 中,它將是:
var database = client.GetDatabase("db_name"); // on this step, the server doesn't know that you want to create db_name
database.ListCollections(null, CancellationToken.None); // the database will be created only after running query, for example "ListCollections"
uj5u.com熱心網友回復:
與貓鼬?如果您使用的是貓鼬,請為新集合創建一個新架構。
啟動后端后,應該創建新集合。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/325171.html
標籤:mongodb 猫鼬 mongodb-查询
