{"action":"created","issue":{"url":"https://api.github.com/repos/treojs/idb-schema/issues/7","repository_url":"https://api.github.com/repos/treojs/idb-schema","labels_url":"https://api.github.com/repos/treojs/idb-schema/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/treojs/idb-schema/issues/7/comments","events_url":"https://api.github.com/repos/treojs/idb-schema/issues/7/events","html_url":"https://github.com/treojs/idb-schema/issues/7","id":144968175,"number":7,"title":"Allowing customization of argument(s) passed to `addCallback` callback","user":{"login":"brettz9","id":20234,"avatar_url":"https://avatars.githubusercontent.com/u/20234?v=3","gravatar_id":"","url":"https://api.github.com/users/brettz9","html_url":"https://github.com/brettz9","followers_url":"https://api.github.com/users/brettz9/followers","following_url":"https://api.github.com/users/brettz9/following{/other_user}","gists_url":"https://api.github.com/users/brettz9/gists{/gist_id}","starred_url":"https://api.github.com/users/brettz9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettz9/subscriptions","organizations_url":"https://api.github.com/users/brettz9/orgs","repos_url":"https://api.github.com/users/brettz9/repos","events_url":"https://api.github.com/users/brettz9/events{/privacy}","received_events_url":"https://api.github.com/users/brettz9/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-03-31T17:37:24Z","updated_at":"2016-04-11T03:58:23Z","closed_at":"2016-04-11T03:58:23Z","body":"I've been working on adding `idb-schema` to `db.js` and have it working and passing our tests, but with a slightly ugly user-facing workaround. With an added API to `idb-schema`, the need for this workaround can be avoided and I think may be useful to other libraries.\r\n\r\nThe issue is that when `callback` is used to build the `upgradeneeded` callback, the callbacks added earlier by `addCallback` will be called with the `upgradeneeded` event, but I'd like to pass our own object as the first argument to allow the user to make db.js-style queries rather than forcing the user to be required to utilize the `upgradeneeded` event.\r\n\r\nWould you be open to a PR which supports a callback argument supplied to the `Schema` constructor (perhaps on an options object instead or as a method called directly after Schema()) which, if present, will itself be passed the `upgradeneeded` event and the user's callback so that wrapper can determine what to supply to the user's callback?\r\n\r\nUser code:\r\n```js\r\nconst schema = new Schema(function (e, cb) {\r\n    cb(dbJSWrapper(e), e);\r\n}).version(1)\r\n  .addStore('books')\r\n  .addCallback((dbJSObject, e) => {\r\n    // do something custom\r\n  })\r\n```\r\n\r\nIn the db.js code:\r\n```js\r\nrequest.onupgradeneeded = e => {\r\n    const idbschema = new IdbSchema();\r\n    userOptions.schemaBuilder(idbschema); // Allow the db.js user to build their schema with `addCallback()`, etc.\r\n\r\n    idbschema.callback()(dbJSObject, e); // Pass our own custom object for making db.js queries\r\n};\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/treojs/idb-schema/issues/comments/208151749","html_url":"https://github.com/treojs/idb-schema/issues/7#issuecomment-208151749","issue_url":"https://api.github.com/repos/treojs/idb-schema/issues/7","id":208151749,"user":{"login":"brettz9","id":20234,"avatar_url":"https://avatars.githubusercontent.com/u/20234?v=3","gravatar_id":"","url":"https://api.github.com/users/brettz9","html_url":"https://github.com/brettz9","followers_url":"https://api.github.com/users/brettz9/followers","following_url":"https://api.github.com/users/brettz9/following{/other_user}","gists_url":"https://api.github.com/users/brettz9/gists{/gist_id}","starred_url":"https://api.github.com/users/brettz9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettz9/subscriptions","organizations_url":"https://api.github.com/users/brettz9/orgs","repos_url":"https://api.github.com/users/brettz9/repos","events_url":"https://api.github.com/users/brettz9/events{/privacy}","received_events_url":"https://api.github.com/users/brettz9/received_events","type":"User","site_admin":false},"created_at":"2016-04-11T03:58:23Z","updated_at":"2016-04-11T03:58:23Z","body":"I guess I can work around the original issue, and I've added in a PR my more recent suggestions for adding open/upgrade methods, so I'm closing this issue. Thanks..."}}