{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-connector-postgresql/issues/50","labels_url":"https://api.github.com/repos/strongloop/loopback-connector-postgresql/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-connector-postgresql/issues/50/comments","events_url":"https://api.github.com/repos/strongloop/loopback-connector-postgresql/issues/50/events","html_url":"https://github.com/strongloop/loopback-connector-postgresql/issues/50","id":54054644,"number":50,"title":"How to ONLY insert given properties and not send NULL to database.","user":{"login":"aars","id":129898,"avatar_url":"https://avatars.githubusercontent.com/u/129898?v=3","gravatar_id":"","url":"https://api.github.com/users/aars","html_url":"https://github.com/aars","followers_url":"https://api.github.com/users/aars/followers","following_url":"https://api.github.com/users/aars/following{/other_user}","gists_url":"https://api.github.com/users/aars/gists{/gist_id}","starred_url":"https://api.github.com/users/aars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aars/subscriptions","organizations_url":"https://api.github.com/users/aars/orgs","repos_url":"https://api.github.com/users/aars/repos","events_url":"https://api.github.com/users/aars/events{/privacy}","received_events_url":"https://api.github.com/users/aars/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-12T13:43:51Z","updated_at":"2015-01-12T16:41:08Z","closed_at":null,"body":"I have a TIMESTAMP column named created in my users table. The database knows the default value for it, and I want the database to handle this.\r\n\r\nHow can I make sure that a Model.save() creates an SQL query that only inserts the properties I tell it to?\r\n\r\nFor example:\r\n\r\n``` javascript\r\nAccess.create([{ // Extends User\r\n  uuid: rID.uuid, // Some uuid I got from some other Model\r\n  username: 'aaron',\r\n  password: 'test',\r\n  email: 'test@test.test'\r\n}]);\r\n```\r\n\r\nEnds up trying to insert every column of the Model/Table.\r\n\r\n``` sql\r\nINSERT INTO \"public\".\"access\" (\"uuid\",\"name\",\"username\",\"password\",\"role\",\"acl\",\"created\",\"expired\",\"realm\",\"credentials\",\"challenges\",\"email\",\"emailverified\",\"verificationtoken\",\"status\",\"lastupdated\")\r\n\r\nFailing row contains (42, 0b81bb8b-1962-4b01-9f4c-87a0938bf94b, owner, null, aaron, $2a$10$GtfE7X4BR.eyf/AI7qwHQegYdqEaEzIFnLgMy5mqkc6JQ8bB6j3e2, {\"all\": \"rw\"}, null, null, null, null, null, test@test.test, null, null, null, null).\r\n```\r\n\r\nHow can I prevent all these null values? I want (need) my database to handle default values. I know I can set the default values ALSO in my model definition, but I don't see why I should have to. This would also mean that a simple misconfigured timezone on an application server will mess up these Date fields, since the Default Value was decided on by my NodeJS Application and not in the database.\r\n"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-connector-postgresql/issues/comments/69599928","html_url":"https://github.com/strongloop/loopback-connector-postgresql/issues/50#issuecomment-69599928","issue_url":"https://api.github.com/repos/strongloop/loopback-connector-postgresql/issues/50","id":69599928,"user":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars.githubusercontent.com/u/540892?v=3","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"created_at":"2015-01-12T16:41:08Z","updated_at":"2015-01-12T16:41:08Z","body":"One option is to skip columns that don't have corresponding values set in the data object during create(). For example, if data.role === undefined, we should not insert it."}}