{"id":26327638,"url":"https://github.com/lambda-orm/lambdaorm","last_synced_at":"2025-03-15T20:20:29.559Z","repository":{"id":38363359,"uuid":"364992230","full_name":"lambda-orm/lambdaorm","owner":"lambda-orm","description":"λORM \"We don't reinvent the wheel, we improve it\"","archived":false,"fork":false,"pushed_at":"2024-04-10T10:15:22.000Z","size":21927,"stargazers_count":8,"open_issues_count":9,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-04-11T10:26:10.839Z","etag":null,"topics":["api-rest","cli","lambda","orm","schema"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/lambdaorm","language":"TypeScript","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/lambda-orm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-05-06T17:46:46.000Z","updated_at":"2024-04-14T22:40:27.551Z","dependencies_parsed_at":"2023-09-26T11:49:09.687Z","dependency_job_id":"66f19390-8f47-459a-a4f5-8effde162826","html_url":"https://github.com/lambda-orm/lambdaorm","commit_stats":{"total_commits":1008,"total_committers":5,"mean_commits":201.6,"dds":0.5972222222222222,"last_synced_commit":"63d907248b4e15abbe59cd2d814c14926fc8dd36"},"previous_names":["lambda-orm/lambdaorm","flaviolionelrita/lambdaorm"],"tags_count":218,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambda-orm%2Flambdaorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambda-orm%2Flambdaorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambda-orm%2Flambdaorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambda-orm%2Flambdaorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambda-orm","download_url":"https://codeload.github.com/lambda-orm/lambdaorm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243785953,"owners_count":20347556,"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":["api-rest","cli","lambda","orm","schema"],"created_at":"2025-03-15T20:20:29.061Z","updated_at":"2025-03-15T20:20:29.549Z","avatar_url":"https://github.com/lambda-orm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# λORM\n\n[![Join the community on GitHub Discussions](https://img.shields.io/badge/Join%20the%20community-on%20GitHub%20Discussions-blue.svg)](https://github.com/lambda-orm/lambdaorm/discussions)\n[![Slack](https://img.shields.io/badge/chat-on%20slack-orange)](https://join.slack.com/t/nuevoespaciod-xo58767/shared_invite/zt-29ix7pc2r-Wd_ZBWnWRDv_5DM4NPtVhQ)\n[![Gitter](https://badges.gitter.im/lambdaorm/community.svg)](https://app.gitter.im/#/room/#lambdaorm-how-to-contribute:gitter.im)\n[![Discord](https://img.shields.io/badge/chat-on%20discord-orange)](https://discord.com/invite/yXT6XBX2)\n[![Wiki](https://img.shields.io/badge/doc-wiki-yellow)](https://github.com/lambda-orm/lambdaorm/wiki)\n[![language typescript](https://img.shields.io/badge/language-typescript-blue)](https://www.npmjs.com/package/lambdaorm)\n[![npm version](https://img.shields.io/badge/npm-10.2.5-green)](https://www.npmjs.com/package/lambdaorm)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Github CI](https://img.shields.io/badge/Github-CI-red.svg)](https://github.com/lambda-orm/lambdaorm/actions?query=workflow%3A%22publish%22)\n[![CLI](https://img.shields.io/badge/Api-CLI-blue.svg)](https://www.npmjs.com/package/lambdaorm-cli)\n[![Api REST](https://img.shields.io/badge/Api-REST-blue.svg)](https://github.com/lambda-orm/lambdaorm-svc)\n\nλORM is an ORM that allows us to perform distributed queries on different database engines.\n\nIn λORM, queries are defined using lambda expressions based on a domain model which abstracts us from the infrastructure. For example, in a query you can obtain or modify records from different entities, where some persist in MySQL, others in Postgres, and others in Mongo.\n\nλORM allows you to define different scenarios for the same domain. For example, in one scenario, the infrastructure may consist of distributed instances across SQL Server, MongoDB, and Oracle, while in another scenario it may be a single Postgres instance. This allows the [CQRS](https://microservices.io/patterns/data/cqrs.html) pattern to be implemented through configuration, without needing to write a single line of code. [view example](https://github.com/lambda-orm/lambdaorm-labs/tree/main/labs/svc/04-northwind-cqrs-with-kafka)\n\nIn addition to being used as a Node.js library, it can be consumed from a command line interface (CLI), a REST service, or a REST service client in other programming languages.\n\n## Query Language\n\nExample of a query where orders and their details associated with a customer are obtained:\n\n```Typescript\nconst query = (country: string) =\u003e Products\n    .map(p =\u003e ({ category: p.category.name, largestPrice: max(p.price) }))    \n    .filter(p =\u003e (p.price \u003e 5 \u0026\u0026 p.supplier.country == country) || (p.inStock \u003c 3))    \n    .having(p =\u003e max(p.price) \u003e 50)\n    .sort(p =\u003e desc(p.largestPrice));\n// Run the query passing the value of the country parameter\nconst result = await orm.execute(query, { country: 'ARG' });\n```\n\nIn this example:\n\n- Define a query that returns a list of product categories along with the maximum price of each category.\n- Filter products based on price and supplier's country or stock availability\n- Group products by category and calculate the maximum price\n- Map each product to an object with category name and maximum price\n- Sort the products by largest price in descending order\n\n**view:** [queries](https://github.com/lambda-orm/lambdaorm/wiki/Query-Language) |\n[select](https://github.com/lambda-orm/lambdaorm/wiki/Select) |\n[join](https://github.com/lambda-orm/lambdaorm/wiki/Join) |\n[grouping](https://github.com/lambda-orm/lambdaorm/wiki/Grouping) |\n[include](https://github.com/lambda-orm/lambdaorm/wiki/Include) |\n[insert](https://github.com/lambda-orm/lambdaorm/wiki/Insert) |\n[bulkInsert](https://github.com/lambda-orm/lambdaorm/wiki/BulkInsert) |\n[update](https://github.com/lambda-orm/lambdaorm/wiki/Update) |\n[delete](https://github.com/lambda-orm/lambdaorm/wiki/Delete) |\n[repository](https://github.com/lambda-orm/lambdaorm/wiki/Repository) |\n[usage](https://github.com/lambda-orm/lambdaorm/wiki/Usage) |\n[metadata](https://github.com/lambda-orm/lambdaorm/wiki/Metadata)\n\n### Include\n\nThe include allows us to obtain the entity data and its relationships in the same query. These data may be in different databases. \\\nIn this example the query is expressed as a text string. (Which is another alternative to the lambda expression)\n\n```Typescript\nimport { orm } from '../../lib'\n(async () =\u003e {\n  try {\n    await orm.init('./config/northwind.yaml')\n    const query = `Orders\n\t.filter(p =\u003e p.id === id)\n\t.include(p =\u003e \n\t  [ p.customer.map(p =\u003e p.name), \n\t    p.details\n             .include(p =\u003e \n                 p.product\n  \t          .include(p =\u003e p.category.map(p =\u003e p.name))\n\t\t  .map(p =\u003e p.name))\n\t     .map(p =\u003e [p.quantity, p.unitPrice])\n\t   ]\n         )`\n\tconst params = { id: 102 }\n\tconst result = await orm.execute(query, params, { stage: 'PostgreSQL' })\n\tconsole.log(JSON.stringify(result, null, 2))\n   } catch (error:any) {\n\tconsole.error(error.message)\n   } finally {\n       await orm.end()\n   }\n})()\n```\n\n**Result:**\n\n```json\n[\n  {\n    \"id\": 102,\n    \"customerId\": \"SPLIR\",\n    \"employeeId\": 7,\n    \"orderDate\": \"1996-11-07T23:00:00.000Z\",\n    \"requiredDate\": \"1996-12-05T23:00:00.000Z\",\n    \"shippedDate\": \"1996-11-14T23:00:00.000Z\",\n    \"shipViaId\": 1,\n    \"freight\": 8.63,\n    \"name\": \"Split Rail Beer \u0026 Ale\",\n    \"address\": \"P.O. Box 555\",\n    \"city\": \"Lander\",\n    \"region\": \"WY\",\n    \"postalCode\": \"82520\",\n    \"country\": \"USA\",\n    \"customer\": {\n      \"name\": \"Split Rail Beer \u0026 Ale\"\n    },\n    \"details\": [\n      {\n        \"quantity\": 24,\n        \"unitPrice\": 5.9,\n        \"product\": {\n          \"name\": \"Tourtire\",\n          \"category\": {\n            \"name\": \"Meat/Poultry\"\n          }\n        }\n      }\n    ]\n  }\n]\n```\n\n**more info:** [include](https://github.com/lambda-orm/lambdaorm/wiki/Include)\n\n## Schema Configuration\n\nThrough the schema, you can define entities, enumerations, indexes, unique keys, default values, constraints, mapping, sources, stages, listeners, etc. The schema can be defined in a JSON or YAML format. Conditions or actions are performed using the same [expression language](https://www.npmjs.com/package/3xpr) that is used to define queries.\n\n**view:**  [schema](https://github.com/lambda-orm/lambdaorm/wiki/Schema) |\n[definition](https://github.com/lambda-orm/lambdaorm/wiki/SchemaDefinition) |\n[use](https://github.com/lambda-orm/lambdaorm/wiki/Schema-Use) |\n[expressions](https://github.com/lambda-orm/lambdaorm/wiki/SchemaDefinition-Expressions) |\n[environment Variables](https://github.com/lambda-orm/lambdaorm/wiki/SchemaDefinition-EnvironmentVariables) |\n[composite](https://github.com/lambda-orm/lambdaorm/wiki/SchemaDefinition-Composite) |\n[listener](https://github.com/lambda-orm/lambdaorm/wiki/SchemaExample-Listener) |\n[multiple stages](https://github.com/lambda-orm/lambdaorm/wiki/SchemaExample-MultiplesStages) |\n[multiple sources](https://github.com/lambda-orm/lambdaorm/wiki/SchemaExample-StageMultiplesSources) |\n[push](https://github.com/lambda-orm/lambdaorm/wiki/SchemaSynchronization-Push) |\n[pull](https://github.com/lambda-orm/lambdaorm/wiki/SchemaSynchronization-Pull) |\n[fetch](https://github.com/lambda-orm/lambdaorm/wiki/SchemaSynchronization-Fetch) |\n[introspect](https://github.com/lambda-orm/lambdaorm/wiki/SchemaSynchronization-Introspect) |\n[incorporate](https://github.com/lambda-orm/lambdaorm/wiki/SchemaSynchronization-Incorporate)\n\n## Features\n\n- Supports MySQL, MariaDB, PostgresSQL, Oracle, SqlServer, SqlJs and MongoDB.\n- [Query Language](https://github.com/lambda-orm/lambdaorm/wiki/Query-Language)\n\t- Simple query language based on javascript lambda expressions.\n\t- Can write the expression as javascript code or as a string\n\t- DQL, DML and DDL clauses\n\t- Implicit joins and group by\n\t- [Eager loading using the Include() method.](https://github.com/lambda-orm/lambdaorm/wiki/Include)\n\t- [Query expression metadata](https://github.com/lambda-orm/lambdaorm/wiki/Metadata)\n- [Repositories and custom repositories](https://github.com/lambda-orm/lambdaorm/wiki/Repository)\n- [Transactions and distributed transactions](https://github.com/lambda-orm/lambdaorm/wiki/Transaction)\n- [Schema Configuration](https://github.com/lambda-orm/lambdaorm/wiki/Schema)\n  - Decoupling the domain model from infrastructure\n\t- Configuration in json or yml formats\n\t- Definition of mappings between domain and infrastructure\n\t- Extends entities\n\t- Environment variables\n  - define indices, unique keys and constraints\n  - Conditions and actions are based on the expression engine [3xpr](https://www.npmjs.com/package/3xpr)\n  - [Synchronization](https://github.com/lambda-orm/lambdaorm/wiki/SchemaSynchronization)\n- Performance and Optimization\n  - [BulkInsert](https://github.com/lambda-orm/lambdaorm/wiki/BulkInsert)\n  - High performance queries\n  - Connection pooling\n- [Listeners and subscribers](https://github.com/lambda-orm/lambdaorm/wiki/SchemaExample-Listener)\n- TypeScript and JavaScript support\n- [CLI Support](https://www.npmjs.com/package/lambdaorm-cli)\n- [REST API Support](https://github.com/lambda-orm/lambdaorm-svc)\n- HTTP Client Support:  [Node Client](https://www.npmjs.com/package/lambdaorm-client-node)\n  [Kotlin Client](https://github.com/lambda-orm/lambdaorm-client-kotlin) (In Progress)\n\n## Contributing\n\nWould you like to contribute? Read [our contribution guidelines](https://github.com/lambda-orm/lambdaorm/blob/main/CONTRIBUTING.md) to learn more. There are many ways to help!\n\n## Documentation\n\nFull documentation is available in the [Wiki](https://github.com/lambda-orm/lambdaorm/wiki).\n\n## All Labs\n\nYou can access various labs at [lambdaorm labs](https://github.com/lambda-orm/lambdaorm-labs)\n\n## Related projects\n\n- [Lambda ORM CLI](https://www.npmjs.com/package/lambdaorm-cli): Command line interface for λORM\n- [Lambda ORM Service](https://github.com/lambda-orm/lambdaorm-svc): REST service for λORM\n- [Client Node](https://www.npmjs.com/package/lambdaorm-client-node): HTTP client for λORM\n- [Client Kotlin](https://github.com/lambda-orm/lambdaorm-client-kotlin) : HTTP client for λORM for Kotlin\n- [3xpr](https://www.npmjs.com/package/3xpr): Extensible expression engine, which allows evaluating mathematical and logical expressions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambda-orm%2Flambdaorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambda-orm%2Flambdaorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambda-orm%2Flambdaorm/lists"}