2016-04-22 22 views
0

我有時連接到3.2數據庫,有時連接到2.7數據庫,具體取決於部署。偶爾,有一個功能在3.2上可用,但不是2.7,所以我需要檢查版本。這是我試過的,based on the docs在流星中獲取數據庫版本

> Meteor.users.rawDatabase().version() 
TypeError: Object [object Object] has no method 'version' 

如何獲取流星的數據庫版本?

回答

1

你可以嘗試使用RemoteCollectionDriver訪問底層node.js native driver,然後使用管理數據庫的操作:

const adminDb = MongoInternals.defaultRemoteCollectionDriver().mongo.db.admin() 
adminDb.buildInfo((err, info) => { console.log(info.version); })