{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/269","repository_url":"https://api.github.com/repos/tgriesser/knex","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/269/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/269/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/269/events","html_url":"https://github.com/tgriesser/knex/issues/269","id":33296144,"number":269,"title":"Chained update with increment?","user":{"login":"imiric","id":1009277,"avatar_url":"https://avatars.githubusercontent.com/u/1009277?v=3","gravatar_id":"","url":"https://api.github.com/users/imiric","html_url":"https://github.com/imiric","followers_url":"https://api.github.com/users/imiric/followers","following_url":"https://api.github.com/users/imiric/following{/other_user}","gists_url":"https://api.github.com/users/imiric/gists{/gist_id}","starred_url":"https://api.github.com/users/imiric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imiric/subscriptions","organizations_url":"https://api.github.com/users/imiric/orgs","repos_url":"https://api.github.com/users/imiric/repos","events_url":"https://api.github.com/users/imiric/events{/privacy}","received_events_url":"https://api.github.com/users/imiric/received_events","type":"User","site_admin":false},"labels":[{"id":23356638,"url":"https://api.github.com/repos/tgriesser/knex/labels/bug","name":"bug","color":"fc2929","default":true},{"id":232918327,"url":"https://api.github.com/repos/tgriesser/knex/labels/PR%20please","name":"PR please","color":"bfe5bf","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2014-05-12T10:28:15Z","updated_at":"2016-12-28T16:43:23Z","closed_at":null,"body":"Sorry if I'm missing something, but I can't seem to be able to use `.increment()` along with updating other fields on the table.\n\nFor instance, I'd want to do:\n\n``` js\nknex('products')\n  .whereIn('id', ids)\n  .update({'updated_at': new Date()})\n  .increment('count', 1);\n```\n\nBut running this I get:\n\n```\nPossibly unhandled Error: The query type has already been set to update\n```\n\nI understand why it happens, I just think it would be nice to be able to add other fields to the update.\n\nAlternatively, maybe we could remove `.increment()` altogether and somehow in the `.update()` itself be able to reference the table's columns. Maybe something like:\n\n``` js\nknex('products')\n  .whereIn('id', ids)\n  .update({\n    'updated_at': new Date(),\n    'count': function() {\n      return this + 1;\n    }\n  });\n```\n\nYeah, not sure about the \"this + 1\" part, but maybe have another way of saying \"the existing column value\". This would avoid the need for `.increment()` and `.decrement()`.\n\nI realize I could write this using `.raw()`, but it would be nice to have it in the library.\n\nWhat do you think?\n"},"comment":{"url":"https://api.github.com/repos/tgriesser/knex/issues/comments/269503556","html_url":"https://github.com/tgriesser/knex/issues/269#issuecomment-269503556","issue_url":"https://api.github.com/repos/tgriesser/knex/issues/269","id":269503556,"user":{"login":"seiyria","id":763609,"avatar_url":"https://avatars.githubusercontent.com/u/763609?v=3","gravatar_id":"","url":"https://api.github.com/users/seiyria","html_url":"https://github.com/seiyria","followers_url":"https://api.github.com/users/seiyria/followers","following_url":"https://api.github.com/users/seiyria/following{/other_user}","gists_url":"https://api.github.com/users/seiyria/gists{/gist_id}","starred_url":"https://api.github.com/users/seiyria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seiyria/subscriptions","organizations_url":"https://api.github.com/users/seiyria/orgs","repos_url":"https://api.github.com/users/seiyria/repos","events_url":"https://api.github.com/users/seiyria/events{/privacy}","received_events_url":"https://api.github.com/users/seiyria/received_events","type":"User","site_admin":false},"created_at":"2016-12-28T16:43:23Z","updated_at":"2016-12-28T16:43:23Z","body":"just wanted to chime in and say glad that I found this issue - it happened to me as well and it was pretty confusing."}}
{"actor":{"display_login":"seiyria"}}