{"action":"opened","issue":{"url":"https://api.github.com/repos/source/source/issues/7","labels_url":"https://api.github.com/repos/source/source/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/source/source/issues/7/comments","events_url":"https://api.github.com/repos/source/source/issues/7/events","html_url":"https://github.com/source/source/issues/7","id":61832500,"number":7,"title":"Counts in Profile","user":{"login":"pat-riley","id":8563327,"avatar_url":"https://avatars.githubusercontent.com/u/8563327?v=3","gravatar_id":"","url":"https://api.github.com/users/pat-riley","html_url":"https://github.com/pat-riley","followers_url":"https://api.github.com/users/pat-riley/followers","following_url":"https://api.github.com/users/pat-riley/following{/other_user}","gists_url":"https://api.github.com/users/pat-riley/gists{/gist_id}","starred_url":"https://api.github.com/users/pat-riley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pat-riley/subscriptions","organizations_url":"https://api.github.com/users/pat-riley/orgs","repos_url":"https://api.github.com/users/pat-riley/repos","events_url":"https://api.github.com/users/pat-riley/events{/privacy}","received_events_url":"https://api.github.com/users/pat-riley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-15T15:00:08Z","updated_at":"2015-03-15T15:00:08Z","closed_at":null,"body":"The goal here is that every time we query for information about a given user, I want to return a count (number) of the number of items in the article, follows, and followers array.\r\n\r\nHere is the User Schema located in `server/app/models/user.js`\r\n```js\r\nvar UserSchema = new Schema({\r\n  username: { type: String, required: true, unique: true },\r\n  // password: { type: String, required: true },\r\n  email: String,\r\n  gravatarURL: String,\r\n  authID: String,\r\n  counts: {\r\n    articles: Number,\r\n    follows: Number,\r\n    followed_by: Number\r\n  },\r\n  articles : [{ type: Schema.Types.ObjectId, ref: 'Article' }],\r\n  follows: [{ type: Schema.Types.ObjectId, ref: 'User' }],\r\n  followers: [{ type: Schema.Types.ObjectId, ref: 'User' }]\r\n});\r\n```\r\n\r\nAnd here is an example in `server/app/controllers/users.js` where I am returning information about a given user. \r\n\r\n```js\r\nexports.getUser = function(req, res) {\r\n\tvar id = req.params.id;\r\n\r\n\tUser.findById(id, function(err, users) {\r\n\t\tif (err)\r\n\t\t\tres.send(err);\r\n\t\tres.json(users);\r\n\t});\r\n};\r\n```\r\n\r\nWhere can I populate the counts data in the user model every time we get information about a user?"}}