{"id":22258422,"url":"https://github.com/stephenwakely/worm","last_synced_at":"2026-03-11T20:01:28.173Z","repository":{"id":14144278,"uuid":"16849930","full_name":"StephenWakely/worm","owner":"StephenWakely","description":"ORM for Node JS","archived":false,"fork":false,"pushed_at":"2015-06-03T20:11:51.000Z","size":524,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-20T09:29:06.389Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StephenWakely.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":"2014-02-14T21:27:43.000Z","updated_at":"2015-01-20T21:52:04.000Z","dependencies_parsed_at":"2022-09-26T20:00:56.231Z","dependency_job_id":null,"html_url":"https://github.com/StephenWakely/worm","commit_stats":null,"previous_names":["fungushumungus/worm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/StephenWakely/worm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenWakely%2Fworm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenWakely%2Fworm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenWakely%2Fworm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenWakely%2Fworm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StephenWakely","download_url":"https://codeload.github.com/StephenWakely/worm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenWakely%2Fworm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30398159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T18:46:22.935Z","status":"ssl_error","status_checked_at":"2026-03-11T18:46:17.045Z","response_time":84,"last_error":"SSL_read: 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":[],"created_at":"2024-12-03T08:16:23.283Z","updated_at":"2026-03-11T20:01:28.156Z","avatar_url":"https://github.com/StephenWakely.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"WORM (Worm Object Relational Mapper)\n\nWORM is an ORM for Javascript that enables you to use POJsO's (Plain Old Javascript Objects) mapped against your relationhal database.\n\nIt is currently tested against Postgress, but in theory should be possible to make it work against any standard relational database.\n\n====\n##Step 1\n\nDefine your business objects. Currently there needs to be a one-to-one mapping between your database tables and your business objects. With a well designed database this should be typically the case. You can add methods to define your business logic and validation to these objects as well.\n\nSay we have a customer with multiple addresses:\n\n```\n  var customer={\n    id: null,\n    firstName: '',\n    lastName: '',\n    addresses: [],\n\n    getHomeAddress: function() {\n      for (var a in this.addresses) {\n        if (a.type === 'Home')\n          return a;\n      }\n    }\n  };\n\n  var address={\n    id: null,\n    customer_id: null,\n    street: '',\n    town: '',\n    country: '',\n    postcode: '',\n    type: 'Home'\n  };\n```\n===\n\n##Step 2\n\nRegister these objects with WORM and define any relationships.\n\n```\n  var worm = require('worm');\n\n  worm.registerSchema({\n    table: 'customer',\n    fields: customer,\n    relationships: [{field: addresses,\n                      maps_to: 'address',\n                      with_field: 'customer_id'\n    }]\n  });\n\n  worm.registerSchema({\n    table: 'address',\n    fields: address\n  });\n```\n\n===\n\n##Step 3\n\nSetup the connection to the database.\n```\n  var pg = require('pg')\n\n  var connection = function() {\n    return new pg.Client(dbconfig);\n  };\n```\n===\n\n##Step 4\n\nQuery the database, and play with your objects.\n```\n  var customers = worm.model('customer', connection);\n  var addresses = worm.model('address', connection);\n\n  // Get Mr Smith from the database\n  var smith = customers.get({where: \"firstName = $1\", params['Smith']});\n\n  // Create a new address\n  var address = addresses.create({street: '13 Mongle Road',\n                                  town: 'Spooton Rabbit',\n                                  type: 'Business'});\n\n  // Add the address to Mr Smith\n  smith.addresses.push(address);\n\n  // Save the changes\n  customer.saveModel(smith);\n```\n====\n\n##Step 5\n\nSit back and code your apps logic\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenwakely%2Fworm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenwakely%2Fworm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenwakely%2Fworm/lists"}