Collection.rawDatabase()。repairDatabase不是一个函数

时间:2017-06-30 13:22:29

标签: javascript node.js mongodb meteor

如何在Meteor中修复数据库。下面是我现在正在执行的代码。

Meteor.methods({
  'repairDB'(){
    Users.rawDatabase().repairDatabase();
    return true;
  }
});

以下是我所面临的错误。

I20170630-18:43:57.601(5.5)? Exception while invoking method 'repairDB' TypeErro
r: Users.rawDatabase(...).repairDatabase is not a function
I20170630-18:43:57.604(5.5)?     at [object Object].Meteor.methods.repairDB (imp
orts/startup/server/methods.js:46:33)
I20170630-18:43:57.607(5.5)?     at maybeAuditArgumentChecks (packages/ddp-serve
r/livedata_server.js:1737:12)
I20170630-18:43:57.609(5.5)?     at packages/ddp-server/livedata_server.js:719:1
9
I20170630-18:43:57.612(5.5)?     at [object Object]._.extend.withValue (packages
\meteor.js:1122:17)
I20170630-18:43:57.633(5.5)?     at packages/ddp-server/livedata_server.js:717:4
0
I20170630-18:43:57.635(5.5)?     at [object Object]._.extend.withValue (packages
\meteor.js:1122:17)
I20170630-18:43:57.638(5.5)?     at packages/ddp-server/livedata_server.js:715:4
6
I20170630-18:43:57.639(5.5)?     at [object Object]._.extend.protocol_handlers.m
ethod (packages/ddp-server/livedata_server.js:689:23)
I20170630-18:43:57.641(5.5)?     at packages/ddp-server/livedata_server.js:559:4
3

1 个答案:

答案 0 :(得分:0)

我使用了Users.rawDatabase().command({repairDatabase:1}).then(d => console.log(d));

我收到了以下输出:

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

I20170630-20:23:05.462(5.5)? { ok: 1 }