Javascript Meteor.users使用字符串参数访问

Javascript Meteor.users使用字符串参数访问,javascript,mongodb,meteor,Javascript,Mongodb,Meteor,我试图列出项目团队的成员,这些成员作为用户ID存储在projectMembers数组中。我使用{{#each projectMember}来迭代当前成员,以显示其用户名(如果存在)或电子邮件地址。不幸的是,我遇到了一个无法调试的错误 控制台日志显示适当的userid作为字符串元素发送到Meteor.users.findOne(),但控制台上显示错误 String {0: "o", 1: "o", 2: "T", 3: "w", 4: "4", 5: "T", 6: "i", 7: "5", 8:

我试图列出项目团队的成员,这些成员作为用户ID存储在projectMembers数组中。我使用{{#each projectMember}来迭代当前成员,以显示其用户名(如果存在)或电子邮件地址。不幸的是,我遇到了一个无法调试的错误

控制台日志显示适当的userid作为字符串元素发送到Meteor.users.findOne(),但控制台上显示错误

String {0: "o", 1: "o", 2: "T", 3: "w", 4: "4", 5: "T", 6: "i", 7: "5", 8: "j", 9: "u", 10: "L", 11: "5", 12: "v", 13: "B", 14: "F", 15: "X", 16: "r", length: 17} createProject.js?5f1e645071dc1f451f671ec1d93aa9051ebadc0b:26
Exception from Deps recompute function: TypeError: Object 0 has no method 'substr'
at http://localhost:3000/packages/minimongo.js?4ee0ab879b747ffce53b84d2eb80d456d2dcca6d:1370:13
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:159:22)
at compileDocumentSelector (http://localhost:3000/packages/minimongo.js?4ee0ab879b747ffce53b84d2eb80d456d2dcca6d:1369:5)
at _.extend._compileSelector (http://localhost:3000/packages/minimongo.js?4ee0ab879b747ffce53b84d2eb80d456d2dcca6d:1346:12)
at new Minimongo.Matcher (http://localhost:3000/packages/minimongo.js?4ee0ab879b747ffce53b84d2eb80d456d2dcca6d:1289:27)
at new LocalCollection.Cursor (http://localhost:3000/packages/minimongo.js?4ee0ab879b747ffce53b84d2eb80d456d2dcca6d:142:20)
at LocalCollection.find (http://localhost:3000/packages/minimongo.js?4ee0ab879b747ffce53b84d2eb80d456d2dcca6d:125:10)
at LocalCollection.findOne (http://localhost:3000/packages/minimongo.js?4ee0ab879b747ffce53b84d2eb80d456d2dcca6d:188:15)
at _.extend.findOne (http://localhost:3000/packages/mongo-livedata.js?cf17a2975aa7445f0db2377c2af07e5efc240958:320:29)
at String.Template.manageProject.helpers.email (http://localhost:3000/client/helpers/createProject.js?5f1e645071dc1f451f671ec1d93aa9051ebadc0b:27:29) debug.js:41
不同寻常的是,我可以在控制台上运行Meteor.users.findOne(“ooTw4Ti5juL5vBFXr”),并获得预期的返回值

相关模板代码:

    {{#each projectMembers}}
    <li class="userRow">
        <div class="lineWrapper">
        <div class="destroyUser"></div>
        <div class="displayUser">
             <div class="userNames">{{email}}</div>
        </div>
        <div class="projectPermissions">
            <div class="admin"><button type="button" class="btn btn-add btn-success btn-sm"><span title="Administrator" class="glyphicon glyphicon-cog {{isAdmin}}"> Admin</span></button></div>
            <div class="edit"><button type="button" class="btn btn-add btn-success btn-sm"><span title="Edit" class="glyphicon glyphicon-pencil {{canEdit}}"> Edit</span></button></div>
            <div class="download"><button type="button" class="btn btn-add btn-success btn-sm"><span title="Download" class="glyphicon glyphicon-download-alt {{canDownload}}"> Download</span></button></div>
            <div class="print"><button type="button" class="btn btn-add btn-success btn-sm"><span title="Print" class="glyphicon glyphicon-print {{canPrint}}"> Print</span></button></div>
            <div class="view"><button type="button" class="btn btn-add btn-success btn-sm"><span title="View" class="glyphicon glyphicon-eye-open {{canView}}"> View</span></button></div>
        </div>
        </div>
    </li>
{{/each}}
meteor文档显示,将字符串传递给meteor.users.findOne()应该是合法的,因此任何关于我做错了什么的见解都是非常值得赞赏的

提前感谢。

我正在与用户查找进行协商。我发现在try..catch块中包装Meteor.users.findOne调用可以提供临时解决方案。在我的情况下,这似乎会被再次调用后。我仍在努力寻找一个完整的解决方案,但在我的情况下,它只在我未登录时才会显现

更新:

您可能需要这样的临时补丁:

try{
  var userDude=Meteor.users.findOne(temp);
} catch(e){
  console.log(e);
}
更新:

我已经开始阅读有关Meteor的订阅模式。我发现了一些可能对你有用的方法。有一种方法可以检查帐户服务是否已配置。我认为这可能对你有用:

if(Accounts.loginServicesConfigured()){
  var userDude=Meteor.users.findOne(temp);
}
更新:

根据parties示例,我在服务器上创建了以下内容:

Meteor.publish("directory", function () {
  return Meteor.users.find({}, {fields: {emails: 1, profile: 1}});
});
在我的客户机中,我正在订阅此服务:

var directorySubscription = Meteor.subscribe("directory");
然后我检查订阅是否已准备就绪:

if(directorySubcription.ready()){
  var userDude=Meteor.users.findOne(temp);
}

您正在迭代一个名为projectMembers的数组,对吗?你不应该迭代一组用户吗?也许帮助程序projectMembers应该返回类似Users.find的内容(_id:{$in:projectMembers});有趣的当我登录时,我会一直得到它。你能把你正在使用的try..catch代码发给我吗?我的代码在这里()try..catch是第一个代码块。(在我的回答中增加了一个例子)。这真的很奇怪。我正在浏览accounts-admin-ui-bootstrap-3meterolite包,它的功能与我正在尝试的类似。不过我还没弄明白。检查Accounts.loginServicesConfigured()方法,我想这可能就是你要找的。把它放在waitOn下的路由器中似乎就行了。谢谢
if(directorySubcription.ready()){
  var userDude=Meteor.users.findOne(temp);
}