{"id":13465162,"url":"https://github.com/SpoonX/wetland","last_synced_at":"2025-03-25T13:33:07.808Z","repository":{"id":47415624,"uuid":"63080652","full_name":"SpoonX/wetland","owner":"SpoonX","description":"A Node.js ORM, mapping-based. Works with MySQL, PostgreSQL, SQLite and more.","archived":false,"fork":false,"pushed_at":"2023-01-11T01:48:08.000Z","size":2888,"stargazers_count":259,"open_issues_count":9,"forks_count":19,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-22T16:04:12.673Z","etag":null,"topics":["database","mysql","nodejs","orm","postgres","sqlite","typescript","wetland"],"latest_commit_sha":null,"homepage":"https://wetland.spoonx.org/","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/SpoonX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-11T15:41:33.000Z","updated_at":"2024-11-24T04:15:50.000Z","dependencies_parsed_at":"2023-02-08T22:00:40.671Z","dependency_job_id":null,"html_url":"https://github.com/SpoonX/wetland","commit_stats":null,"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fwetland","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fwetland/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fwetland/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fwetland/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpoonX","download_url":"https://codeload.github.com/SpoonX/wetland/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245471297,"owners_count":20620916,"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":["database","mysql","nodejs","orm","postgres","sqlite","typescript","wetland"],"created_at":"2024-07-31T14:01:02.074Z","updated_at":"2025-03-25T13:33:07.398Z","avatar_url":"https://github.com/SpoonX.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# ![Wetland](https://cdn.rawgit.com/SpoonX/wetland/391040eba795183550bfff01d7c0ca56d01b5530/wetland.svg)\n\n[![Build Status](https://travis-ci.org/SpoonX/wetland.svg?branch=master)](https://travis-ci.org/SpoonX/wetland)\n[![npm version](https://badge.fury.io/js/wetland.svg)](https://badge.fury.io/js/wetland)\n[![Slack Status](https://spoonx-slack.herokuapp.com/badge.svg)](https://spoonx-slack.herokuapp.com)\n\nWetland is a modern object-relational mapper (ORM) for node.js based on the JPA-spec.\nIt strikes a balance between ease and structure, allowing you to get started quickly, without losing flexibility or features.\n\n**New!** Take a look at our [wetland tutorial](https://wetland.spoonx.org/Tutorial/setting-up.html).\n\n**New!** Wetland CLI now has its [own repository](https://github.com/SpoonX/wetland-cli). `npm i -g wetland-cli`.\n\n**New!** Wetland has a nice entity generator. Let us do the heavy lifting. [Repository can be found here](https://github.com/SpoonX/wetland-generator-entity).\n\n## Features\n\nWetland is based on the [JPA-spec](http://download.oracle.com/otndocs/jcp/persistence-2_1-fr-eval-spec/index.html) and therefore has some similarities to Hibernate and Doctrine. While some aspects of the ORM have been adapted to perform better in the Node.js environment and don't follow the specification to the letter for that reason, the JPA specification is a stable and well written specification that makes wetland structured and performant.\n\nSome of the major features provided include:\n\n* Unit of work\n* Derived tables\n* Migrations\n* Transactions\n* Entity manager\n* Cascaded persists\n* Deep joins\n* Repositories\n* QueryBuilder\n* Entity mapping\n* Optimized state manager\n* Recipe based hydration\n* [More...](https://wetland.spoonx.org)\n\n## Installation\n\nTo install wetland run the following command:\n\n`npm i --save wetland`\n\nTypings are provided by default for TypeScript users. No additional typings need installing.\n\n## Plugins / essentials\n\n- [Wetland CLI](https://github.com/SpoonX/wetland-cli) `npm i -g wetland-cli`\n- [Express middleware](https://github.com/SpoonX/express-wetland)\n- [Sails.js hook](https://github.com/SpoonX/sails-hook-wetland)\n- [Trailpack](https://github.com/SpoonX/trailpack-wetland)\n- [Entity generator](https://github.com/SpoonX/wetland-generator-entity)\n\n## Compatibility\n\n* All operating systems\n* Node.js 8.0+\n\n## Gotchas\n\n- When using sqlite3, foreign keys are disabled (this is due to alter table not working for foreign keys with sqlite).\n\n## Usage\n\nThe following is a snippet to give you an idea what it's like to work with wetland.\nFor a much more detailed explanation, [head to the documentation.](https://wetland.spoonx.org).\n\n```js\nconst Wetland = require('wetland').Wetland;\nconst Foo     = require('./entity/foo').Foo;\nconst Bar     = require('./entity/foo').Bar;\nconst wetland = new Wetland({\n  stores: {\n    simple: {\n      client    : 'mysql',\n      connection: {\n        user    : 'root',\n        database: 'testdatabase'\n      }\n    }\n  },\n  entities: [Foo, Bar]\n});\n\n// Create the tables. Async process, only here as example.\n// use .getSQL() (not async) in stead of apply (async) to get the queries.\nlet migrator = wetland.getMigrator().create();\nmigrator.apply().then(() =\u003e {});\n\n// Get a manager scope. Call this method for every context (e.g. requests).\nlet manager = wetland.getManager();\n\n// Get the repository for Foo\nlet repository = manager.getRepository(Foo);\n\n// Get some results, and join.\nrepository.find({name: 'cake'}, {joins: ['candles', 'baker', 'baker.address']})\n  .then(results =\u003e {\n    // ...\n  });\n```\n\n### Entity example\n\n#### Javascript\n\n```js\nconst { UserRepository } = require('../repository/UserRepository');\n\nclass User {\n  static setMapping(mapping) {\n    // Adds id, updatedAt and createdAt for your convenience.\n    mapping.autoFields();\n\n    mapping.entity({ repository: UserRepository })\n    mapping.field('dateOfBirth', { type: 'datetime' });\n  }\n}\n\nmodule.exports.User = User;\n```\n\n#### Typescript\n\n```js\nimport { entity, autoFields, field } from 'wetland';\nimport { UserRepository } from '../repository/UserRepository';\n\n@entity({ repository: UserRepository })\n@autoFields()\nexport class User {\n  @field({ type: 'datetime' })\n  public dateOfBirth: Date;\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSpoonX%2Fwetland","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSpoonX%2Fwetland","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSpoonX%2Fwetland/lists"}