{"id":30450313,"url":"https://github.com/mathiaspius/enorm","last_synced_at":"2025-08-23T13:26:59.059Z","repository":{"id":273002695,"uuid":"850082654","full_name":"MathiasPius/enorm","owner":"MathiasPius","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-23T23:19:48.000Z","size":423,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T00:25:22.582Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/MathiasPius.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-30T21:00:19.000Z","updated_at":"2025-03-23T23:20:15.000Z","dependencies_parsed_at":"2025-03-24T00:22:06.525Z","dependency_job_id":"c4226beb-57f7-4298-87b9-d6f64edba7db","html_url":"https://github.com/MathiasPius/enorm","commit_stats":null,"previous_names":["mathiaspius/erm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MathiasPius/enorm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasPius%2Fenorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasPius%2Fenorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasPius%2Fenorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasPius%2Fenorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MathiasPius","download_url":"https://codeload.github.com/MathiasPius/enorm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasPius%2Fenorm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271749048,"owners_count":24814115,"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-08-23T02:00:09.327Z","response_time":69,"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":"2025-08-23T13:26:56.678Z","updated_at":"2025-08-23T13:26:59.042Z","avatar_url":"https://github.com/MathiasPius.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enorm is Not an ORM.\n\nEnorm is a library for using [SQLx](https://github.com/launchbadge/sqlx)-compatible storage backends as a persistence layer for an [Entity-Component-System](https://en.wikipedia.org/wiki/Entity_component_system) (ECS) architecture.\n\nWhile similar to [Object-Relational Mapping](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping), Enorm enforces simplicity, and prevents hugely complex queries by imposing the following ECS-based limits and patterns:\n\n### 1. Enorm can only store *Components*\n\nA component is (in most cases) a plain struct type, containing [zero](#marker-traits) or more SQLx-de/serializable fields.\n\nSince a component can only be made up of fields that can each be stored in a single column of the underlying database, they are very \"flat\". One-to-Many or Many-to-Many relationships can only be expressed through *Entity ID* fields, referencing other *Entities*.\n\n```rust\n#[derive(Component)]\nstruct Name(String);\n\n#[derive(Component)]\nstruct Age(u8);\n```\n\n### 2. *Entities* are just the sum of their *Component Instances*.\n\nEntities don't exist, except as *Component Instances* with the same associated *Entity ID*.\n\nYou can neither create nor destroy an *Entity* directly. Entities are \"created\" when a *Component* is instantiated with its *Entity ID*, and cease to exist when the last *Component Instance* associated with it is deleted.\n\n```rust\n// \"Andrea\" is created, using a tuple of Components:\nenorm.insert(1234, \u0026(Name(\"Andrea\"), Age(32)));\n\n// Andrea ceases to exist.\nenorm.remove::\u003c(Name, Age)\u003e(1234);\n```\n\n### 3. *Archetypes* are a convenience for grouping *Components*.\n\nLike *Entities*, *Archetypes* don't exist per se, but simply groups *Components*\ninto meta-types, that can be used in place of querying components individually (or through tuples):\n\n```rust\n// Instead of inserting components as collections of tuples,\n// we can define such a collection as an Archetype:\n#[derive(Archetype)]\nstruct Person {\n    name: Name,\n    age: Age,\n}\n \nenorm.insert(1234, \u0026Person {\n    name: Name(\"Andrea\"),\n    age: Age(32)\n});\n\nenorm.get::\u003cPerson\u003e(1234); // \u003c-- Person { name: Name(\"Andrea\"), age: Age(32) }\n\n// But Archetypes are just an abstraction, underneath it is still just Components:\nenorm.get::\u003cName\u003e(1234); // \u003c-- Name(\"Andrea\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiaspius%2Fenorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathiaspius%2Fenorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiaspius%2Fenorm/lists"}