{"id":23053698,"url":"https://github.com/component/model-http","last_synced_at":"2025-04-03T04:25:05.098Z","repository":{"id":13378666,"uuid":"16066588","full_name":"component/model-http","owner":"component","description":"A plugin that adds an HTTP transport to a model.","archived":false,"fork":false,"pushed_at":"2014-01-20T09:42:27.000Z","size":136,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-14T09:40:07.939Z","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/component.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-20T09:41:59.000Z","updated_at":"2014-01-20T09:42:28.000Z","dependencies_parsed_at":"2022-08-22T23:50:15.648Z","dependency_job_id":null,"html_url":"https://github.com/component/model-http","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fmodel-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fmodel-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fmodel-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fmodel-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/component","download_url":"https://codeload.github.com/component/model-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246935385,"owners_count":20857401,"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","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-16T00:19:14.919Z","updated_at":"2025-04-03T04:25:05.055Z","avatar_url":"https://github.com/component.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# model-http\n\n  A plugin that adds an HTTP transport to a model.\n\n## Installation\n\n    $ component install component/model-http\n\n## Example\n\n```js\nvar model = require('model');\nvar http = require('model-http');\n\n/**\n * User model.\n */\n\nvar User = model('user')\n  .use(http('/users'))\n  .attr('id')\n  .attr('name');\n\n/**\n * Usage...\n */\n\nvar user = new User({ name: 'Fred' });\n\nuser.save(function (err) {\n  if (err) throw err;\n  store('user', id);\n});\n\n/**\n * Later...\n */\n\nvar id = store('user');\n\nUser.get(id, function (err, user) {\n  if (err) throw err;\n  render(user);  \n});\n```\n\n## API\n\n#### http(base)\n\n  Return a plugin function for a given `base` URL. For HTTP calls that required an identifier, the model's `primary` key will be appended to the `base` URL.\n\n#### .get(id, fn)\n\n  Get a model by `id` and invoke `fn(err, model)`.\n\n#### .remove(id, fn)\n\n  Remove a model by `id` and invoke `fn(err, model)`.\n\n#### .getAll(fn)\n \n  Get all models and invoke `fn(err, models)`.\n\n#### .removeAll([fn])\n \n  Remove all models and optionally invoke `fn(err)`.\n\n#### #url()\n\n  Return the URL for a given model instance.\n\n#### #isNew()\n\n  Check whether a model has been saved yet.\n\n#### #save([fn])\n\n  Save a model, optionally invoking `fn(err)`.\n\n#### #remove([fn])\n\n  Remove a model, optionally invoking `fn(err)`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fmodel-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomponent%2Fmodel-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fmodel-http/lists"}