{"id":23644433,"url":"https://github.com/allnulled/webmarket","last_synced_at":"2025-10-09T19:34:55.904Z","repository":{"id":269068445,"uuid":"906323932","full_name":"allnulled/webmarket","owner":"allnulled","description":"Wrapper for IndexedDB.","archived":false,"fork":false,"pushed_at":"2024-12-20T16:48:35.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-13T08:46:22.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allnulled.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-20T16:36:17.000Z","updated_at":"2025-01-09T04:49:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"22bbb1ff-8cbd-4388-a56e-2bd78ec7c965","html_url":"https://github.com/allnulled/webmarket","commit_stats":null,"previous_names":["allnulled/webmarket"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/allnulled/webmarket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fwebmarket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fwebmarket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fwebmarket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fwebmarket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allnulled","download_url":"https://codeload.github.com/allnulled/webmarket/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fwebmarket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001958,"owners_count":26083244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-28T12:20:07.517Z","updated_at":"2025-10-09T19:34:55.889Z","avatar_url":"https://github.com/allnulled.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webmarket\n\nWrapper for IndexedDB.\n\n## Installation\n\n```sh\nnpm install --save @allnulled/webmarket\n```\n\nThen:\n\n```html\n\u003cscript src=\"node_modules/@allnulled/webmarket/webmarket.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n```js\nconst wm = await Webmarket.open();\n// @TODO: operations\n```\n\n## Operations\n\nThe `window.Wemarket` global class has some methods:\n\n - `static create(dbName)`: creates an instance.\n    - Receives `String:dbName`, the name of the database.\n    - Returns `Webmarket` type.\n - `static open(dbName)`: creates and initializes an instance.\n    - Receives `String:dbName`, the name of the database.\n    - Returns `Promise\u003cWebmarket\u003e` type.\n - `static init(dbName)`\n    - Receives `String:dbName`, the name of the database.\n    - Return `Promise\u003cWebmarket\u003e` type, and returns `wm.init()`.\n - `static listDatabases()`\n    - Receives nothing.\n    - Returns the list of names of databases found.\n - `constructor(dbName = \"webmarket\")`\n    - Receives `String:dbName`, the name of the database.\n    - Creates the object only. You still need to call to `wm.init()`.\n - `async init()`\n    - Receives nothing. Uses the `this.dbName` set on the constructor.\n    - Ensures the current store and returns an internal IDB object.\n - `async changeDatabase(dbName)`\n    - Receives `String:dbName`, the name of the database.\n    - Changes the name of the database, and calls `wm.init()` again.\n - `async select()`\n    - Receives nothing. Filters are complicated in IDB.\n    - Returns a list of all the items.\n - `async selectById(id)`\n    - Receives `Integer:id`, the `id` of the row to select.\n    - Returns the item by id, if found.\n - `async insertOne(data)`\n    - Receives `Object:item`, the `item` to insert.\n    - Inserts one item.\n    - Returns the inserted `id`.\n - `async insertMany(items)`\n    - Receives `Array\u003cObject\u003e:items`, the `items` to insert.\n    - Inserts a list of items.\n    - Returns the inserted `id`s in a list.\n - `async updateOne(id, data)`\n    - Receives `Integer:id`, the `id` of the row to update.\n    - Updates one item.\n    - Returns the updated `id`.\n - `async deleteOne(id)`\n    - Receives `Integer:id`, the `id` of the row to delete.\n    - Deletes one item.\n    - Returns nothing.\n\n## How it better works?\n\nJust remember this.\n\nDatabases are directories. Rows are files indexed by `id`.\n\nThere are no stores with webmarket, no schema versions, no schema modifications.\n\nOnly 1 directory and N files. Only 1 database and N registries.\n\n### Steps\n\n1. You `open` database and store. `wm = Webmarket.open(dbName)`\n2. You operate the CRUD like so:\n   1. `all = await wm.select()`\n   1. `one = await wm.selectById(1)`\n   1. `id = await wm.insertOne({})`\n   1. `ids = await wm.insertMany([{}, {}, {}])`\n   1. `id = await wm.updateOne(1, {})`\n   1. `await wm.deleteOne(1)`\n\nBy default, you work on `\"webmarket\"` database, and `webstore` store.\n\nThe idea is to only alter the `database` name.\n\n## Test\n\n```js\n// Creamos una instancia de Webmarket\nconst wm = await Webmarket.open(\"testDB\");\n\n// Insertamos un solo dato\nconst id = await wm.insertOne({ name: \"Item 1\", description: \"First item\" });\nconsole.log(`Inserted item with ID: ${id}`);\n\n// Insertamos varios datos\nconst ids = await wm.insertMany([\n    { name: \"Item 2\", description: \"Second item\" },\n    { name: \"Item 3\", description: \"Third item\" }\n]);\nconsole.log(`Inserted items with IDs: ${ids.join(\", \")}`);\n\n// Recuperamos todos los elementos\nconst items = await wm.select();\nconsole.log(\"All items:\", items);\n\n// Actualizamos un elemento\nawait wm.updateOne(id, { name: \"Updated Item 1\", description: \"Updated description\" });\nconsole.log(\"Updated item with ID:\", id);\n\n// Recuperamos el elemento actualizado\nconst updatedItem = await wm.selectById(id);\nconsole.log(\"Updated item:\", updatedItem);\n\n// Eliminamos un elemento\nawait wm.deleteOne(id);\nconsole.log(\"Deleted item with ID:\", id);\n\n// Recuperamos todos los elementos después de la eliminación\nconst remainingItems = await wm.select();\nconsole.log(\"Remaining items:\", remainingItems);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fwebmarket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallnulled%2Fwebmarket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fwebmarket/lists"}