{"id":17821513,"url":"https://github.com/a179346/knex-increment-upsert","last_synced_at":"2026-04-11T14:35:56.583Z","repository":{"id":57289330,"uuid":"438486200","full_name":"a179346/knex-increment-upsert","owner":"a179346","description":"knex insert on duplicate key update \u0026 increment","archived":false,"fork":false,"pushed_at":"2022-02-14T06:56:58.000Z","size":66,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-03T03:37:12.974Z","etag":null,"topics":["increment","javascript","knex","mysql","node","nodejs","on-duplicate-key","postgresql","query","sql","sqlite3","typescript","upsert"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a179346.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-15T03:48:55.000Z","updated_at":"2021-12-15T08:54:58.000Z","dependencies_parsed_at":"2022-09-04T07:50:27.955Z","dependency_job_id":null,"html_url":"https://github.com/a179346/knex-increment-upsert","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/a179346/knex-increment-upsert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fknex-increment-upsert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fknex-increment-upsert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fknex-increment-upsert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fknex-increment-upsert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a179346","download_url":"https://codeload.github.com/a179346/knex-increment-upsert/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fknex-increment-upsert/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31684525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["increment","javascript","knex","mysql","node","nodejs","on-duplicate-key","postgresql","query","sql","sqlite3","typescript","upsert"],"created_at":"2024-10-27T17:17:56.721Z","updated_at":"2026-04-11T14:35:56.543Z","avatar_url":"https://github.com/a179346.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eknex-increment-upsert 👋\u003c/h1\u003e\n\u003cp\u003e\n  \u003ca href=\"https://github.com/a179346/knex-increment-upsert/actions/workflows/build.yml\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://github.com/a179346/knex-increment-upsert/actions/workflows/build.yml/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/knex-increment-upsert\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/npm/v/knex-increment-upsert?maxAge=3600)\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/a179346/knex-increment-upsert#readme\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/badge/documentation-yes-brightgreen.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/a179346/knex-increment-upsert/graphs/commit-activity\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Maintenance\" src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/a179346/knex-increment-upsert/blob/main/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/github/license/a179346/knex-increment-upsert\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e knex insert and on duplicate key update \u0026 increment\n\n## 🔗 Link\n+ [Github](https://github.com/a179346/knex-increment-upsert#readme)\n+ [npm](https://www.npmjs.com/package/knex-increment-upsert)\n\n## 📥 Install\n\n```sh\nnpm install knex-increment-upsert\n```\n## 🧩 Requirements\n- knex \u003e= `v0.95.0`\n\n## 📖 Usage\n\u003e ### `incrementUpsert(db, tableName, data, incrementColumns?, updateColumns?, trx?)` =\u003e `Promise\u003cnumber[]\u003e`\n- #### Single upsert\n```js\nconst { incrementUpsert } = require('knex-increment-upsert');\nconst knex = require('knex');\n\nconst db = knex({ ... });\n\n// Outputs:\n// insert into `table1` (`inc1`, `pk1`, `pk2`) values (3, 'pk1', 'pk2') on duplicate key update `inc1` = `inc1` + values(`inc1`)\nincrementUpsert(\n  db, \n  'table1', \n  {\n    pk1: 'pk1',\n    pk2: 'pk2',\n    inc1: 3,\n  }, \n  [ 'inc1' ]\n);\n```\n\n- #### Batch upsert\n```js\n// Outputs:\n// insert into `table1` (`col1`, `inc1`, `pk1`, `pk2`) values ('1', 1, '1', '1'), ('2', 2, '2', '2') on duplicate key update `inc1` = `inc1` + values(`inc1`),`col1` = values(`col1`)\nincrementUpsert(\n  db,\n  'table1',\n  [\n    {\n      pk1: '1',\n      pk2: '1',\n      inc1: 1,\n      col1: '1'\n    },\n    {\n      pk1: '2',\n      pk2: '2',\n      inc1: 2,\n      col1: '2'\n    }\n  ],\n  [ 'inc1' ],\n  [ 'col1' ]\n);\n```\n\n## 🙋‍♂️ Author\n\n\n* Github: [@a179346](https://github.com/a179346)\n\n## 🤝 Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check [issues page](https://github.com/a179346/knex-increment-upsert/issues).\n\n## 🌟 Show your support\n\nGive a ⭐️ if this project helped you!\n\n## 📝 License\n\nCopyright © 2021 [a179346](https://github.com/a179346).\u003cbr /\u003e\nThis project is [MIT](https://github.com/a179346/knex-increment-upsert/blob/main/LICENSE) licensed.\n\n***\n_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa179346%2Fknex-increment-upsert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa179346%2Fknex-increment-upsert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa179346%2Fknex-increment-upsert/lists"}