Wetland is a modern, and enterprise grade object-relational mapper (ORM) for node.js.
It allows you to get started quickly, without losing flexibility or features.
Features
Some of the major features provided include:
- Unit of work
- Migrations
- Transactions
- Entity manager
- Cascaded persists
- Deep joins
- Repositories
- QueryBuilder
- Entity mapping
- Optimized state manager
- Recipe based hydration
- More...
Installation
To install wetland run the following command:
npm i --save wetland
Typings are provided by default for TypeScript users. No additional typings need installing.
Compatibility
- All operating systems
- Node.js 6.0+
Gotchas
- When using sqlite3, foreign keys are disabled (this is due to alter table not working for foreign keys with sqlite).
Usage
The following is a snippet to give you an idea what it's like to work with wetland.
For a much more detailed explanation, head to the documention..
const Wetland = require('wetland').Wetland;
const Foo = require('./entity/foo').Foo;
const Bar = require('./entity/foo').Bar;
const wetland = new Wetland({
stores: {
simple: {
client : 'mysql',
connection: {
user : 'root',
database: 'testdatabase'
}
}
},
entities: [Foo, Bar]
});
let migrator = wetland.getMigrator().create();
migrator.apply().then(() => {});
let manager = wetland.getManager();
let repository = manager.getRepository(Foo);
repository.find({name: 'cake'}, {joins: ['candles', 'baker', 'baker.address']})
.then(results => {
});