Skip to content

Commit

Permalink
Merge cb568ee into 074a145
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed Nov 11, 2019
2 parents 074a145 + cb568ee commit 3dc12c5
Show file tree
Hide file tree
Showing 237 changed files with 14,714 additions and 5,493 deletions.
7 changes: 5 additions & 2 deletions .codeclimate.yml
Expand Up @@ -3,7 +3,7 @@ version: "2"
checks:
file-lines:
config:
threshold: 400
threshold: 500
method-lines:
config:
threshold: 30
Expand All @@ -13,6 +13,9 @@ checks:
return-statements:
config:
threshold: 5
method-complexity:
config:
threshold: 7

engines:
duplication:
Expand All @@ -21,4 +24,4 @@ engines:
languages:
typescript:
# make it higher so it does not report bullshit like similarity of abstract method and its implementation
mass_threshold: 55
mass_threshold: 70
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -2,7 +2,9 @@
/dist
/coverage
/temp
/tests/generated-entities
/.idea
/.vscode
/yarn-error.log
/.coveralls.yml
!.gitkeep
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -3,9 +3,8 @@ dist: xenial

node_js:
- '8'
- '9'
- '10'
- '11'
- '12'
- 'node'

services:
Expand All @@ -14,6 +13,7 @@ services:
- postgresql

cache:
yarn: true
directories:
- 'node_modules'

Expand Down
294 changes: 147 additions & 147 deletions CHANGELOG.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Expand Up @@ -15,12 +15,12 @@ or [Stack overflow](https://stackoverflow.com/tags/mikro-orm/).

## Found a bug?

If you find a bug in the source code, you can help by [submitting an issue](https://github.com/B4nan/mikro-orm/issues/new)
or even better, by [submitting a Pull Request](https://github.com/B4nan/mikro-orm/pulls) with a fix.
If you find a bug in the source code, you can help by [submitting an issue](https://github.com/mikro-orm/mikro-orm/issues/new)
or even better, by [submitting a Pull Request](https://github.com/mikro-orm/mikro-orm/pulls) with a fix.

## Missing a feature?

You can *request* a new feature by [submitting an issue](https://github.com/B4nan/mikro-orm/issues/new) to this GitHub
You can *request* a new feature by [submitting an issue](https://github.com/mikro-orm/mikro-orm/issues/new) to this GitHub
Repository. If you would like to *implement* a new feature, please submit an issue with a proposal for your work first,
so we can discuss what is the best way to implement, as well as to be sure nobody else works on that already.

Expand All @@ -38,7 +38,7 @@ is wrong. This will help to understand and fix the issue faster.

Before you submit your pull request consider the following guidelines:

- Search [GitHub](https://github.com/b4nan/mikro-orm/pulls) for an open or closed PR
- Search [GitHub](https://github.com/mikro-orm/mikro-orm/pulls) for an open or closed PR
that relates to your submission. You don't want to duplicate effort.

- Fork the project, install NPM dependencies and start docker to have all databases ready:
Expand Down Expand Up @@ -128,11 +128,11 @@ The commit message format is borrowed from Angular projects and you can find

## CI

We automatically run all pull requests through [Travis CI](https://travis-ci.com/B4nan/mikro-orm).
We automatically run all pull requests through [Travis CI](https://travis-ci.com/mikro-orm/mikro-orm).

- The test suite is ran against MongoDB, MySQL, PostgreSQL and SQLite on all supported Node.JS versions (`yarn test`).
- The code is validated against our Coding Standard (`yarn lint`).
- The code is checked by a static analysis tool ([codeclimate.com](https://codeclimate.com/github/B4nan/mikro-orm)).
- The code is checked by a static analysis tool ([codeclimate.com](https://codeclimate.com/github/mikro-orm/mikro-orm)).

If you break the tests, we cannot merge your code, so please make sure that your code is working before opening a pull request.

Expand Down
91 changes: 68 additions & 23 deletions README.md
Expand Up @@ -133,53 +133,67 @@ MikroORM's documentation, included in this repo in the root directory, is built
There is also auto-generated [CHANGELOG.md](CHANGELOG.md) file based on commit messages
(via `semantic-release`).

## ✨ Core features
## ✨ Core Features

- [Clean and simple entity definition](https://mikro-orm.io/defining-entities/)
- [Clean and Simple Entity Definition](https://mikro-orm.io/defining-entities/)
- [Identity Map](https://mikro-orm.io/identity-map/)
- [Entity references](https://mikro-orm.io/entity-references/)
- [Using entity constructors](https://mikro-orm.io/using-entity-constructors/)
- [Entity References](https://mikro-orm.io/entity-references/)
- [Using Entity Constructors](https://mikro-orm.io/using-entity-constructors/)
- [Modelling Relationships](https://mikro-orm.io/relationships/)
- [Collections](https://mikro-orm.io/collections/)
- [Unit of Work](https://mikro-orm.io/unit-of-work/)
- [Transactions](https://mikro-orm.io/transactions/)
- [Cascading persist and remove](https://mikro-orm.io/cascading/)
- [Using `QueryBuilder`](https://mikro-orm.io/query-builder/)
- [Preloading deeply nested structures via populate](https://mikro-orm.io/nested-populate/)
- [Property validation](https://mikro-orm.io/property-validation/)
- [Lifecycle hooks](https://mikro-orm.io/lifecycle-hooks/)
- [Vanilla JS support](https://mikro-orm.io/usage-with-js/)
- [Preloading Deeply Nested Structures via populate](https://mikro-orm.io/nested-populate/)
- [Property Validation](https://mikro-orm.io/property-validation/)
- [Lifecycle Hooks](https://mikro-orm.io/lifecycle-hooks/)
- [Vanilla JS Support](https://mikro-orm.io/usage-with-js/)
- [Schema Generator](https://mikro-orm.io/schema-generator/)
- [Entity Generator](https://mikro-orm.io/entity-generator/)

## 📦 Example integrations
## 📦 Example Integrations

You can find example integrations for some popular frameworks in the [`mikro-orm-examples` repository](https://github.com/mikro-orm/mikro-orm-examples):

### TypeScript examples
### TypeScript Examples

- [Express + MongoDB](https://github.com/mikro-orm/mikro-orm-examples/tree/master/express-ts)
- [Nest + MySQL](https://github.com/mikro-orm/mikro-orm-examples/tree/master/nest)
- [`nestjs-mikro-orm` module](https://github.com/dario1985/nestjs-mikro-orm)

### JavaScript examples
### JavaScript Examples
- [Express + MongoDB](https://github.com/mikro-orm/mikro-orm-examples/tree/master/express-js)

## 🚀 Quick start
## Articles

- Introducing MikroORM, TypeScript data-mapper ORM with Identity Map
- on [medium.com](https://medium.com/dailyjs/introducing-mikro-orm-typescript-data-mapper-orm-with-identity-map-9ba58d049e02)
- on [dev.to](https://dev.to/b4nan/introducing-mikroorm-typescript-data-mapper-orm-with-identity-map-pc8)
- Handling transactions and concurrency in MikroORM
- on [medium.com](https://medium.com/dailyjs/handling-transactions-and-concurrency-in-mikro-orm-ba80d0a65805)
- on [dev.to](https://dev.to/b4nan/handling-transactions-and-concurrency-in-mikroorm-2cfj)

## 🚀 Quick Start

First install the module via `yarn` or `npm` and do not forget to install the database driver as well:

```
$ yarn add mikro-orm mongodb # for mongo
$ yarn add mikro-orm mysql2 # for mysql
$ yarn add mikro-orm mysql2 # for mysql/mariadb
$ yarn add mikro-orm mariadb # for mysql/mariadb
$ yarn add mikro-orm pg # for postgresql
$ yarn add mikro-orm sqlite # for sqlite
$ yarn add mikro-orm sqlite3 # for sqlite
```

or

```
$ npm i -s mikro-orm mongodb # for mongo
$ npm i -s mikro-orm mysql2 # for mysql
$ npm i -s mikro-orm mysql2 # for mysql/mariadb
$ npm i -s mikro-orm mariadb # for mysql/mariadb
$ npm i -s mikro-orm pg # for postgresql
$ npm i -s mikro-orm sqlite # for sqlite
$ npm i -s mikro-orm sqlite3 # for sqlite
```

Next you will need to enable support for [decorators](https://www.typescriptlang.org/docs/handbook/decorators.html)
Expand All @@ -196,7 +210,6 @@ const orm = await MikroORM.init({
entitiesDirs: ['./dist/entities'], // path to your JS entities (dist), relative to `baseDir`
dbName: 'my-db-name',
clientUrl: '...', // defaults to 'mongodb://localhost:27017' for mongodb driver
autoFlush: false, // read more here: https://mikro-orm.io/unit-of-work/
});
console.log(orm.em); // access EntityManager via `em` property
```
Expand All @@ -223,24 +236,28 @@ app.use((req, res, next) => {
More info about `RequestContext` is described [here](https://mikro-orm.io/identity-map/#request-context).

Now you can start defining your entities (in one of the `entitiesDirs` folders):
Now you can start defining your entities (in one of the `entitiesDirs` folders). This is how
simple entity can look like in mongo driver:

**`./entities/Book.ts`**
**`./entities/MongoBook.ts`**

```typescript
@Entity()
export class Book {
export class MongoBook implements MongoEntity<MongoBook> {

@PrimaryKey()
_id: ObjectID;

@SerializedPrimaryKey()
id: string;

@Property()
title: string;

@ManyToOne()
author: Author;

@ManyToMany({ entity: () => BookTag, inversedBy: 'books' })
@ManyToMany()
tags = new Collection<BookTag>(this);

constructor(title: string, author: Author) {
Expand All @@ -249,8 +266,36 @@ export class Book {
}

}
```

For SQL drivers, use `IdEntity` interface for `id: number` PK:

**`./entities/SqlBook.ts`**

```typescript
@Entity()
export class SqlBook implements IdEntity<SqlBook> {

@PrimaryKey()
id: number;

}
```

If you want to use UUID primary keys, use `UuidEntity` interface:

**`./entities/UuidBook.ts`**

```typescript
import { v4 } from 'uuid';

@Entity()
export class UuidBook implements UuidEntity<UuidBook> {

export interface Book extends IEntity { }
@PrimaryKey()
uuid = v4();

}
```

More information can be found in
Expand Down Expand Up @@ -335,7 +380,7 @@ for details on the process for submitting pull requests to us.

See also the list of contributors who [participated](https://github.com/mikro-orm/mikro-orm/contributors) in this project.

## Show your support
## Show Your Support

Please ⭐️ this repository if this project helped you!

Expand Down
10 changes: 4 additions & 6 deletions ROADMAP.md
Expand Up @@ -11,16 +11,14 @@ discuss specifics.

- Association scopes
- Value transformers (e.g. mapping of `Date` object to formatted string)
- Support for connection pooling in MySQL and PostgresQL
- Computing schema difference based on current database state
- Schema sync (allow automatic synchronization during development)
- Allow generating entities from existing database schema
- Migrations via `umzug`
- Improved support for data types like date, time, enum, timestamp
- Improved support for data types like date, time, timestamp
- Support for RegExp search in SQL drivers
- Collection expressions - support querying parts of collection
- Collection pagination
- Eager loading of associations (allow having some relationship always fetched)
- Composite primary keys
- Map collections
- Single table inheritance #33
- Embedded entities (allow in-lining child entity into parent one with prefixed keys)
- Slow query log
- Optional query params logging
36 changes: 20 additions & 16 deletions docs/_includes/sidebar.html
Expand Up @@ -2,46 +2,50 @@
<h3>Overview</h3>
<ul>
<li><a href="{{ site.github.url | default: site.url }}/installation/">Installation &amp; Usage</a></li>
<li><a href="{{ site.github.url | default: site.url }}/defining-entities/">Defining entities</a></li>
<li><a href="{{ site.github.url | default: site.url }}/defining-entities/">Defining Entities</a></li>
<li><a href="{{ site.github.url | default: site.url }}/entity-manager/">EntityManager</a></li>
<li><a href="{{ site.github.url | default: site.url }}/repositories/">EntityRepository</a></li>
</ul>
<h3>Fundamentals</h3>
<ul>
<li><a href="{{ site.github.url | default: site.url }}/identity-map/">Identity Map and Request Context</a></li>
<li><a href="{{ site.github.url | default: site.url }}/entity-references/">Entity references</a></li>
<li><a href="{{ site.github.url | default: site.url }}/entity-constructors/">Using entity constructors</a></li>
<li><a href="{{ site.github.url | default: site.url }}/entity-references/">Entity References and Reference&lt;T&gt; Wrapper</a></li>
<li><a href="{{ site.github.url | default: site.url }}/entity-constructors/">Using Entity Constructors</a></li>
<li><a href="{{ site.github.url | default: site.url }}/collections/">Collections</a></li>
<li><a href="{{ site.github.url | default: site.url }}/unit-of-work/">Unit of Work</a></li>
<li><a href="{{ site.github.url | default: site.url }}/transactions/">Transactions</a></li>
<li><a href="{{ site.github.url | default: site.url }}/cascading/">Cascading persist and remove</a></li>
<li><a href="{{ site.github.url | default: site.url }}/deployment/">Deployment</a></li>
</ul>
<h3>Advanced features</h3>
<h3>Advanced Features</h3>
<ul>
<li><a href="{{ site.github.url | default: site.url }}/nested-populate/">Smart nested populate</a></li>
<li><a href="{{ site.github.url | default: site.url }}/query-conditions/">Smart query conditions</a></li>
<li><a href="{{ site.github.url | default: site.url }}/nested-populate/">Smart Nested Populate</a></li>
<li><a href="{{ site.github.url | default: site.url }}/query-conditions/">Smart Query Conditions</a></li>
<li><a href="{{ site.github.url | default: site.url }}/query-builder/">Using QueryBuilder</a></li>
<li><a href="{{ site.github.url | default: site.url }}/serializing/">Serializing</a></li>
<li><a href="{{ site.github.url | default: site.url }}/entity-helper/">Updating entity values</a></li>
<li><a href="{{ site.github.url | default: site.url }}/property-validation/">Property validation</a></li>
<li><a href="{{ site.github.url | default: site.url }}/lifecycle-hooks/">Lifecycle hooks</a></li>
<li><a href="{{ site.github.url | default: site.url }}/naming-strategy/">Naming strategy</a></li>
<li><a href="{{ site.github.url | default: site.url }}/metadata-cache/">Metadata cache</a></li>
<li><a href="{{ site.github.url | default: site.url }}/entity-helper/">Updating Entity Values</a></li>
<li><a href="{{ site.github.url | default: site.url }}/property-validation/">Property Validation</a></li>
<li><a href="{{ site.github.url | default: site.url }}/lifecycle-hooks/">Lifecycle Hooks</a></li>
<li><a href="{{ site.github.url | default: site.url }}/naming-strategy/">Naming Strategy</a></li>
<li><a href="{{ site.github.url | default: site.url }}/metadata-cache/">Metadata Cache</a></li>
<li><a href="{{ site.github.url | default: site.url }}/debugging/">Debugging</a></li>
<li><a href="{{ site.github.url | default: site.url }}/schema-generator/">Schema generator</a></li>
<li><a href="{{ site.github.url | default: site.url }}/schema-generator/">Schema Generator</a></li>
<li><a href="{{ site.github.url | default: site.url }}/entity-generator/">Entity Generator</a></li>
<li><a href="{{ site.github.url | default: site.url }}/read-connections/">Read Replica Connections</a></li>
</ul>
<h3>Usage with different drivers</h3>
<h3>Usage with Different Drivers</h3>
<ul>
<li><a href="{{ site.github.url | default: site.url }}/usage-with-sql/">Usage with Postgres, MySQL and SQLite</a></li>
<li><a href="{{ site.github.url | default: site.url }}/usage-with-sql/">Usage with SQL Drivers</a></li>
<li><a href="{{ site.github.url | default: site.url }}/usage-with-mongo/">Usage with MongoDB</a></li>
</ul>
<h3>Recipes</h3>
<ul>
<li><a href="{{ site.github.url | default: site.url }}/usage-with-nestjs/">Usage with NestJS</a></li>
<li><a href="{{ site.github.url | default: site.url }}/usage-with-js/">Usage with Vanilla JS</a></li>
<li><a href="{{ site.github.url | default: site.url }}/custom-driver/">Creating custom driver</a></li>
<li><a href="{{ site.github.url | default: site.url }}/custom-driver/">Creating Custom Driver</a></li>
<li><a href="{{ site.github.url | default: site.url }}/multiple-schemas/">Using Multiple Schemas</a></li>
</ul>
<h3>Example integrations</h3>
<h3>Example Integrations</h3>
<ul>
<li><a href="https://github.com/mikro-orm/mikro-orm-examples/tree/master/express-ts">Express + MongoDB + TypeScript</a></li>
<li><a href="https://github.com/mikro-orm/mikro-orm-examples/tree/master/nest">Nest + MySQL + TypeScript</a></li>
Expand Down
2 changes: 1 addition & 1 deletion docs/cascading.md
Expand Up @@ -115,7 +115,7 @@ await orm.em.removeEntity(book1); // this will remove book1 and its publisher
console.log(book2.publisher, book3.publisher);
```

## Orphan removal
## <a name="orphan-removal"></a> Orphan removal

In addition to `Cascade.REMOVE`, there is also additional and more aggressive remove
cascading mode which can be specified using the `orphanRemoval` flag of the `@OneToOne`
Expand Down

0 comments on commit 3dc12c5

Please sign in to comment.