Shakyamuni177te / wetland

An enterprise grade ORM for Node.js.

Home Page:https://wetland.spoonx.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wetland

Build Status npm version Dependency Status Gitter chat

Wetland is an enterprise grade object-relational mapper (ORM) for node.js.

Note: This module is under active development. While it's usable and well tested, some key features are still in progress.

Features

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

  • Unit of work
  • 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.

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'}, {joins: ['candles', 'baker', 'baker.address']})
  .then(results => {
    // ...
  });

Additional documentation is in progress.

About

An enterprise grade ORM for Node.js.

https://wetland.spoonx.org/

License:MIT License


Languages

Language:TypeScript 99.7%Language:JavaScript 0.3%