{"action":"created","issue":{"url":"https://api.github.com/repos/automategreen/dynamoose/issues/81","repository_url":"https://api.github.com/repos/automategreen/dynamoose","labels_url":"https://api.github.com/repos/automategreen/dynamoose/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/automategreen/dynamoose/issues/81/comments","events_url":"https://api.github.com/repos/automategreen/dynamoose/issues/81/events","html_url":"https://github.com/automategreen/dynamoose/issues/81","id":192277576,"number":81,"title":"Projection on primary key","user":{"login":"jerometea","id":15085505,"avatar_url":"https://avatars.githubusercontent.com/u/15085505?v=3","gravatar_id":"","url":"https://api.github.com/users/jerometea","html_url":"https://github.com/jerometea","followers_url":"https://api.github.com/users/jerometea/followers","following_url":"https://api.github.com/users/jerometea/following{/other_user}","gists_url":"https://api.github.com/users/jerometea/gists{/gist_id}","starred_url":"https://api.github.com/users/jerometea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerometea/subscriptions","organizations_url":"https://api.github.com/users/jerometea/orgs","repos_url":"https://api.github.com/users/jerometea/repos","events_url":"https://api.github.com/users/jerometea/events{/privacy}","received_events_url":"https://api.github.com/users/jerometea/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-29T13:10:04Z","updated_at":"2016-12-01T15:57:54Z","closed_at":null,"body":"Hello,\r\n\r\nI have an user table and the primary key is the username. I want to query on the primary key and project only the firstname and the lastname. But when i do the query on the username Dynamoose retrieves all the attributes.\r\n\r\n**The user schema :** \r\n\r\nvar userSchema = new Schema({\r\n\tusername : {\r\n\t\ttype : String,\r\n\t\thasKey : true,\r\n\t\tindex: {\r\n\t\t\tglobal:true,\r\n\t\t\tname:'firstname-index',\r\n\t\t\tproject:['firstname']\r\n\t\t}\r\n\t},\r\n\tprovider :{\r\n\t\ttype : String,\r\n\t\trequired: true\r\n\t},\r\n\tfirstname:{\r\n\t\ttype:String,\r\n\t},\r\n\tlastname:{\r\n\t\ttype:String\r\n\t},\r\n\tpassword:{\r\n\t\ttype:String\r\n\t}\r\n});\r\n\r\n**The query :** \r\nUser.query('username').eq('usernameTest').exec(function (err, userInfo) {\r\n\t  if(err) {\r\n\t  \tconsole.log(err);\r\n\t  \tconsole.log(\"error\");\r\n\t  }\r\n\t  else {\r\n\t  \tres.json(userInfo);\r\n\t  }\r\n});"},"comment":{"url":"https://api.github.com/repos/automategreen/dynamoose/issues/comments/264211837","html_url":"https://github.com/automategreen/dynamoose/issues/81#issuecomment-264211837","issue_url":"https://api.github.com/repos/automategreen/dynamoose/issues/81","id":264211837,"user":{"login":"brandongoode","id":5034905,"avatar_url":"https://avatars.githubusercontent.com/u/5034905?v=3","gravatar_id":"","url":"https://api.github.com/users/brandongoode","html_url":"https://github.com/brandongoode","followers_url":"https://api.github.com/users/brandongoode/followers","following_url":"https://api.github.com/users/brandongoode/following{/other_user}","gists_url":"https://api.github.com/users/brandongoode/gists{/gist_id}","starred_url":"https://api.github.com/users/brandongoode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandongoode/subscriptions","organizations_url":"https://api.github.com/users/brandongoode/orgs","repos_url":"https://api.github.com/users/brandongoode/repos","events_url":"https://api.github.com/users/brandongoode/events{/privacy}","received_events_url":"https://api.github.com/users/brandongoode/received_events","type":"User","site_admin":false},"created_at":"2016-12-01T15:57:54Z","updated_at":"2016-12-01T15:57:54Z","body":"The reason you receiving all attributes is because 'username' is the hash key.  Dynamoose defaults to using the main table.  \r\n\r\nHere's where the logic is default to the main table:\r\nhttps://github.com/automategreen/dynamoose/blob/951cc453a04b7316dbd273aaccfaeac797d9b792/lib/Query.js#L80"}}
{"actor":{"display_login":"brandongoode"}}