{"action":"created","issue":{"url":"https://api.github.com/repos/thinkjs/thinkjs/issues/908","repository_url":"https://api.github.com/repos/thinkjs/thinkjs","labels_url":"https://api.github.com/repos/thinkjs/thinkjs/issues/908/labels{/name}","comments_url":"https://api.github.com/repos/thinkjs/thinkjs/issues/908/comments","events_url":"https://api.github.com/repos/thinkjs/thinkjs/issues/908/events","html_url":"https://github.com/thinkjs/thinkjs/issues/908","id":266491383,"number":908,"title":"think-mongoose中的populate应该怎么用？","user":{"login":"Leon-cloud","id":9306806,"avatar_url":"https://avatars1.githubusercontent.com/u/9306806?v=4","gravatar_id":"","url":"https://api.github.com/users/Leon-cloud","html_url":"https://github.com/Leon-cloud","followers_url":"https://api.github.com/users/Leon-cloud/followers","following_url":"https://api.github.com/users/Leon-cloud/following{/other_user}","gists_url":"https://api.github.com/users/Leon-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/Leon-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leon-cloud/subscriptions","organizations_url":"https://api.github.com/users/Leon-cloud/orgs","repos_url":"https://api.github.com/users/Leon-cloud/repos","events_url":"https://api.github.com/users/Leon-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/Leon-cloud/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"lushijie","id":4263550,"avatar_url":"https://avatars1.githubusercontent.com/u/4263550?v=4","gravatar_id":"","url":"https://api.github.com/users/lushijie","html_url":"https://github.com/lushijie","followers_url":"https://api.github.com/users/lushijie/followers","following_url":"https://api.github.com/users/lushijie/following{/other_user}","gists_url":"https://api.github.com/users/lushijie/gists{/gist_id}","starred_url":"https://api.github.com/users/lushijie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lushijie/subscriptions","organizations_url":"https://api.github.com/users/lushijie/orgs","repos_url":"https://api.github.com/users/lushijie/repos","events_url":"https://api.github.com/users/lushijie/events{/privacy}","received_events_url":"https://api.github.com/users/lushijie/received_events","type":"User","site_admin":false},"assignees":[{"login":"lushijie","id":4263550,"avatar_url":"https://avatars1.githubusercontent.com/u/4263550?v=4","gravatar_id":"","url":"https://api.github.com/users/lushijie","html_url":"https://github.com/lushijie","followers_url":"https://api.github.com/users/lushijie/followers","following_url":"https://api.github.com/users/lushijie/following{/other_user}","gists_url":"https://api.github.com/users/lushijie/gists{/gist_id}","starred_url":"https://api.github.com/users/lushijie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lushijie/subscriptions","organizations_url":"https://api.github.com/users/lushijie/orgs","repos_url":"https://api.github.com/users/lushijie/repos","events_url":"https://api.github.com/users/lushijie/events{/privacy}","received_events_url":"https://api.github.com/users/lushijie/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2017-10-18T13:24:00Z","updated_at":"2017-10-25T08:50:59Z","closed_at":null,"author_association":"NONE","body":"当创建schema时应该怎么ref，后面查询数据进行populate时出错\r\n```javascript\r\nsrc/model/article.js\r\nmodule.exports = class extends think.Mongoose {\r\n  get schema() {\r\n    return {\r\n      title: String,\r\n      author: {\r\n         type: think.Mongoose.ObjectId\r\n         ref: 'User'\r\n      },\r\n      content: String\r\n    }\r\n  }\r\n}\r\n\r\nsrc/controller/article.js\r\nasync getAction() {\r\n  const article = this.mongoose('article');\r\n  const data = await article.findById(id).populate('author').exec();  // 不行啊！\r\n}\r\n````"},"comment":{"url":"https://api.github.com/repos/thinkjs/thinkjs/issues/comments/339260802","html_url":"https://github.com/thinkjs/thinkjs/issues/908#issuecomment-339260802","issue_url":"https://api.github.com/repos/thinkjs/thinkjs/issues/908","id":339260802,"user":{"login":"lushijie","id":4263550,"avatar_url":"https://avatars1.githubusercontent.com/u/4263550?v=4","gravatar_id":"","url":"https://api.github.com/users/lushijie","html_url":"https://github.com/lushijie","followers_url":"https://api.github.com/users/lushijie/followers","following_url":"https://api.github.com/users/lushijie/following{/other_user}","gists_url":"https://api.github.com/users/lushijie/gists{/gist_id}","starred_url":"https://api.github.com/users/lushijie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lushijie/subscriptions","organizations_url":"https://api.github.com/users/lushijie/orgs","repos_url":"https://api.github.com/users/lushijie/repos","events_url":"https://api.github.com/users/lushijie/events{/privacy}","received_events_url":"https://api.github.com/users/lushijie/received_events","type":"User","site_admin":false},"created_at":"2017-10-25T08:50:59Z","updated_at":"2017-10-25T08:50:59Z","author_association":"OWNER","body":"```\r\nget schema() {\r\n    return {\r\n      title: String,\r\n      author: {\r\n         type: think.Mongoose.ObjectId\r\n         ref: 'User'  // 这里先加上mongoose 的 prefix 前缀，例如前缀为 think_，这里请写 think_User\r\n      },\r\n      content: String\r\n    }\r\n  }\r\n```\r\n\r\n请先按照注释给 ref 加 prefix 前缀。 \r\n\r\n下个小版本会可以直接写 ref: User，我研究一下，发布之后通知你，谢谢"}}
{"actor":{"display_login":"lushijie"}}