Skip to content

Files

Latest commit

Oct 16, 2019
61672b4 · Oct 16, 2019

History

History

doc

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 23, 2018
Sep 30, 2017
Oct 10, 2016
Oct 10, 2016
Oct 16, 2019
Mar 8, 2017
Oct 16, 2018
Jan 11, 2018
Feb 28, 2017
Mar 27, 2019
Feb 9, 2017
Feb 12, 2017
Mar 23, 2017
Oct 20, 2016
Sep 15, 2017

Wetland

Wetland is a modern object-relational mapper (ORM) for node.js.

Features

Wetland is based on the JPA-spec 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.

New! Take a look at our wetland tutorial.

New! Wetland CLI now has its own repository. npm i -g wetland-cli.

New! Wetland has a nice entity generator. Let us do the heavy lifting. Repository can be found here.

The major features this ORM provides are listed below. Looking at the tests will provide more detailed information, pending full documentation.

  • Unit of work
  • Derived tables
  • Transactions
  • Entity manager
  • Manager scopes
  • Cascade persist
  • Deep joins
  • Repositories
  • QueryBuilder
  • Mapping
  • MetaData
  • Entity proxy
  • Collection proxy
  • Criteria parser
  • 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.

Plugins / essentials

Usage

Simple implementation example:

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]
});

// Create the tables. Async process, only here as example.
// use .getSQL() (not async) in stead of apply (async) to get the queries.
let migrator = wetland.getMigrator().create();
migrator.apply().then(() => {});

// Get a manager scope. Call this method for every context (e.g. requests).
let manager = wetland.getManager();

// Get the repository for Foo
let repository = manager.getRepository(Foo);

// Get some results, and join.
repository.find({name: 'cake'}, {populate: ['candles', 'baker', 'baker.address']})
  .then(results => {
    // ...
  });

License

MIT