Meteor - rendering the name of the owner in a list objects

后端 未结 2 2042
独厮守ぢ
独厮守ぢ 2021-01-26 02:38

I\'m getting an object not found error when I try and lookup the owner of the objects i\'m trying to render. I\'m looping through a collection of video clips, that can be updat

相关标签:
2条回答
  • 2021-01-26 02:52

    The app might not be publishing the user id to the client when you are logged out. You can try calling the find method on the server and return the user. Or use a different key for querying/

    0 讨论(0)
  • 2021-01-26 03:01

    I think I've found the solution to this one. After reading about the caching works in Meteor, I've discovered the subscription model and how this relates to meteors minimongo http://docs.meteor.com/#dataandsecurity. The reason this was failing then succeeding was that on the first load the data is still being cached in minimongo. I'm currently checking against Accounts login Services Configured to check if the user data has been loaded. I'm currently using this because I can't find a way to subscribe to the Metor users service, but my guess is that the Accounts login service would rely on the Metor users collection. My current solution looks like this:

    if(Accounts.loginServicesConfigured()){
      var owner = Meteor.users.findOne(this.owner);
      if (owner._id === Meteor.userId())
        return "me";
      return displayName(owner);
    }
    

    Currently this appears to be working correctly. I'm still delving into how to subscribe to this users service.Couple of really userful resferences I found while searching for a solution for this

    • https://github.com/oortcloud/unofficial-meteor-faq
    • http://psychopyko.com/cool-stuff/meteor-6-simple-tips/
    • https://groups.google.com/forum/#!topic/meteor-talk/QKXe7qfBfqg
    0 讨论(0)
提交回复
热议问题