Skip to content

Commit

Permalink
Merge pull request #1 from typeorm/next
Browse files Browse the repository at this point in the history
rebase
  • Loading branch information
dr-bonez committed Apr 16, 2018
2 parents 9ca488e + 4b281e5 commit 0d9fa2f
Show file tree
Hide file tree
Showing 102 changed files with 1,455 additions and 1,038 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -65,6 +65,8 @@ composite check constraint, on table level. E.g. `@Check("chk_name", "name <> 'a
* implemented migrations functionality in all drivers
* CLI commands changed from `migrations:create`, `migrations:generate`, `migrations:revert` and `migrations:run` to `migration:create`, `migration:generate`, `migration:revert` and `migration:run`
* changed the way how migrations work (more info in #1315). Now migration table contains `id` column with auto-generated keys, you need to re-create migrations table or add new column manually.
* entity schemas syntax was changed
* dropped support for WebSql and SystemJS

## 0.1.19

Expand Down
2 changes: 1 addition & 1 deletion ISSUE_TEMPLATE.md
Expand Up @@ -15,7 +15,7 @@
[ ] `postgres`
[ ] `sqlite`
[ ] `sqljs`
[ ] `websql`
[ ] `react-native`

**TypeORM version:**

Expand Down
13 changes: 6 additions & 7 deletions README.md
Expand Up @@ -21,7 +21,7 @@
</div>

TypeORM is an [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)
that can run in NodeJS, Browser, Cordova, PhoneGap and Ionic platforms
that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic and React Native platforms
and can be used with TypeScript and JavaScript (ES5, ES6, ES7).
Its goal is to always support the latest JavaScript features and provide additional features
that help you to develop any kind of application that uses databases - from
Expand Down Expand Up @@ -67,9 +67,9 @@ Some TypeORM features:
* supports closure table pattern
* schema declaration in models or separate configuration files
* connection configuration in json / xml / yml / env formats
* supports MySQL / MariaDB / Postgres / SQLite / Microsoft SQL Server / Oracle / WebSQL / sql.js
* supports MySQL / MariaDB / Postgres / SQLite / Microsoft SQL Server / Oracle / sql.js
* supports MongoDB NoSQL database
* works in NodeJS / Browser / Ionic / Cordova / Electron platforms
* works in NodeJS / Browser / Ionic / Cordova / React Native / Electron platforms
* TypeScript and JavaScript support
* produced code is performant, flexible, clean and maintainable
* follows all possible best practices
Expand Down Expand Up @@ -238,8 +238,7 @@ typeorm init --name MyProject --database mysql
```

Where `name` is the name of your project and `database` is the database you'll use.
Database can be one of the following values: `mysql`, `mariadb`, `postgres`, `sqlite`, `mssql`, `oracle`,
`websql`, `mongodb`.
Database can be one of the following values: `mysql`, `mariadb`, `postgres`, `sqlite`, `mssql`, `oracle`, `mongodb`, `cordova`, `react-native`.

This command will generate a new project in the `MyProject` directory with the following files:

Expand Down Expand Up @@ -534,8 +533,7 @@ createConnection({

We are using MySQL in this example, but you can use any other supported database.
To use another database, simply change the `type` in the options to the database type you are using:
mysql, mariadb, postgres, sqlite, mssql, oracle,
websql, cordova or mongodb.
mysql, mariadb, postgres, sqlite, mssql, oracle, cordova, react-native or mongodb.
Also make sure to use your own host, port, username, password and database settings.

We added our Photo entity to the list of entities for this connection.
Expand Down Expand Up @@ -1248,6 +1246,7 @@ There are a few repositories which you can clone and start with:
* [Example how to use TypeORM with MongoDB](https://github.com/typeorm/typeorm-typescript-mongo-example)
* [Example how to use TypeORM in a Cordova/PhoneGap app](https://github.com/typeorm/cordova-example)
* [Example how to use TypeORM with an Ionic app](https://github.com/typeorm/ionic-example)
* [Example how to use TypeORM with React Native](https://github.com/typeorm/react-native-example)

## Extensions

Expand Down
17 changes: 6 additions & 11 deletions docs/connection-options.md
Expand Up @@ -5,8 +5,8 @@
* [`mysql` / `mariadb` connection options](#mysql--mariadb-connection-options)
* [`postgres` connection options](#postgres-connection-options)
* [`sqlite` connection options](#sqlite-connection-options)
* [`websql` connection options](#websql-connection-options)
* [`cordova` connection options](#cordova-connection-options)
* [`react-native` connection options](#react-native-connection-options)
* [`mssql` connection options](#mssql-connection-options)
* [`mongodb` connection options](#mongodb-connection-options)
* [`sql.js` connection options](#sqljs-connection-options)
Expand All @@ -20,7 +20,7 @@ Connection options is a connection configuration object you pass to `createConne
## Common connection options

* `type` - Database type. You must specify what database engine you use.
Possible values are "mysql", "postgres", "mariadb", "sqlite", "cordova", "oracle", "mssql", "websql", "mongodb", "sqljs".
Possible values are "mysql", "postgres", "mariadb", "sqlite", "cordova", "oracle", "mssql", "mongodb", "sqljs", "react-native".
This option is required.

* `name` - Connection name. You'll use it to get connection you need using `getConnection(name: string)`
Expand Down Expand Up @@ -171,21 +171,16 @@ See [SSL options](https://github.com/mysqljs/mysql#ssl-options).

* `database` - Database path. For example "./mydb.sql"

## `websql` connection options
## `cordova` connection options

* `database` - Database name

* `version` - Version string of the database

* `description` - Database description

* `size` - The size of the database

## `cordova` connection options
* `location` - Where to save the database. See [cordova-sqlite-storage](https://github.com/litehelpers/Cordova-sqlite-storage#opening-a-database) for options.

## `react-native` connection options
* `database` - Database name

* `location` - Where to save the database. See [cordova-sqlite-storage](https://github.com/litehelpers/Cordova-sqlite-storage#opening-a-database) for options.
* `location` - Where to save the database. See [react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage#opening-a-database) for options.

## `mssql` connection options

Expand Down
4 changes: 2 additions & 2 deletions docs/entities.md
Expand Up @@ -7,7 +7,7 @@
* [Column types](#column-types)
* [Column types for `mysql` / `mariadb`](#column-types-for-mysql--mariadb)
* [Column types for `postgres`](#column-types-for-postgres)
* [Column types for `sqlite` / `websql`](#column-types-for-sqlite--websql--cordova)
* [Column types for `sqlite` / `cordova` / `react-native`](#column-types-for-sqlite--cordova--react-native)
* [Column types for `mssql`](#column-types-for-mssql)
* [`simple-array` column type](#simple-array-column-type)
* [`simple-json` column type](#simple-json-column-type)
Expand Down Expand Up @@ -254,7 +254,7 @@ or
`circle`, `path`, `polygon`, `cidr`, `enum`, `inet`, `macaddr`, `bit`, `bit varying`,
`varbit`, `tsvector`, `tsquery`, `uuid`, `xml`, `json`, `jsonb`

### Column types for `sqlite` / `websql` / `cordova`
### Column types for `sqlite` / `cordova` / `react-native`

`int`, `int2`, `int8`, `integer`, `tinyint`, `smallint`, `mediumint`, `bigint`, `decimal`,
`numeric`, `float`, `double`, `real`, `double precision`, `datetime`, `varying character`,
Expand Down
29 changes: 7 additions & 22 deletions docs/supported-platforms.md
Expand Up @@ -11,10 +11,9 @@ TypeORM was tested on Node.js version 4 and above.

## Browser

There is an experimental version of TypeORM that runs in the browser using WebSQL.
There are two ways how it can be used in browser:
You can use [sql.js](https://github.com/kripken/sql.js) in the browser.

* **Webpack / ES2015 Module**
**Webpack configuration**

In the `browser` folder the package also includes a version compiled as a ES2015 module. If you want to use a different loader this is the point to start. Prior to TypeORM 0.1.7, the package is setup in a way that loaders like webpack will automatically use the `browser` folder. With 0.1.7 this was dropped to support Webpack usage in Node.js projects. This means, that the `NormalModuleReplacementPlugin` has to be used to insure that the correct version is loaded for browser projects. The configuration in your webpack config file, for this plugin looks like this:

Expand All @@ -27,28 +26,11 @@ There are two ways how it can be used in browser:
]
```

* **SystemJS**

If you want to use SystemJS as a module loader than three precompiled files are included for you to use.

```
- typeorm-browser.js
- typeorm-browser.min.js (Minified version)
- typeorm-browser.js.map (Sourcemap)
```

Since these files are generated by the TypeScript compiler they are affected by the [issue, that SystemJS 0.20 does not support them](https://github.com/systemjs/systemjs/issues/1587). When using SystemJS@0.19.47 everything works.
For an example see [typeorm/browser-example](https://github.com/typeorm/browser-example).

**Example of configuration**

```typescript
createConnection({
type: "websql",
database: "test",
version: 1,
description: "test database",
size: 2 * 1024 * 1024,
type: "sqljs",
entities: [
Photo
],
Expand All @@ -71,8 +53,11 @@ TypeORM is able to run on Cordova, PhoneGap, Ionic apps using the
You have the option to choose between module loaders just like in browser package.
For an example how to use TypeORM in Cordova see [typeorm/cordova-example](https://github.com/typeorm/cordova-example) and for Ionic see [typeorm/ionic-example](https://github.com/typeorm/ionic-example). **Important**: For use with Ionic, a custom webpack config file is needed! Please checkout the example to see the needed changes.

## React Native
TypeORM is able to on React Native apps using the [react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage) plugin. For an example see [typeom/react-native-example](https://github.com/typeorm/react-native-example).

## NativeScript

In the next releases we are planning to support NativeScript platform as well.

Please feel free to join a community and help us with new features and supporting a new platforms!
Please feel free to join a community and help us with new features and supporting a new platforms!
55 changes: 4 additions & 51 deletions gulpfile.ts
Expand Up @@ -9,8 +9,6 @@ const del = require("del");
const shell = require("gulp-shell");
const replace = require("gulp-replace");
const rename = require("gulp-rename");
const file = require("gulp-file");
const uglify = require("gulp-uglify");
const mocha = require("gulp-mocha");
const chai = require("chai");
const tslint = require("gulp-tslint");
Expand Down Expand Up @@ -70,53 +68,19 @@ export class Gulpfile {
"!./src/typeorm-model-shim.ts",
"!./src/platform/PlatformTools.ts"
])
.pipe(gulp.dest("./build/systemjs/typeorm"))
.pipe(gulp.dest("./build/browser/src"));
}

/**
* Creates special main file for browser build.
*/
@Task()
browserCopyMainBrowserFile() {
return gulp.src("./package.json", { read: false })
.pipe(file("typeorm.ts", `export * from "./typeorm/index";`))
.pipe(gulp.dest("./build/systemjs"));
}

/**
* Replaces PlatformTools with browser-specific implementation called BrowserPlatformTools.
*/
@Task()
browserCopyPlatformTools() {
return gulp.src("./src/platform/BrowserPlatformTools.template")
.pipe(rename("PlatformTools.ts"))
.pipe(gulp.dest("./build/systemjs/typeorm/platform"))
.pipe(gulp.dest("./build/browser/src/platform"));
}

/**
* Runs files compilation of browser-specific source code.
*/
@MergedTask()
browserCompileSystemJS() {
const tsProject = ts.createProject("tsconfig.json", {
outFile: "typeorm-browser.js",
module: "system",
"lib": ["es5", "es6", "dom"],
typescript: require("typescript")
});
const tsResult = gulp.src(["./build/systemjs/**/*.ts", "./node_modules/reflect-metadata/**/*.d.ts", "./node_modules/@types/**/*.ts"])
.pipe(sourcemaps.init())
.pipe(tsProject());

return [
tsResult.js
.pipe(sourcemaps.write(".", { sourceRoot: "", includeContent: true }))
.pipe(gulp.dest("./build/package"))
];
}

@MergedTask()
browserCompile() {
const tsProject = ts.createProject("tsconfig.json", {
Expand All @@ -136,21 +100,10 @@ export class Gulpfile {
];
}

/**
* Uglifys all code.
*/
@Task()
browserUglify() {
return gulp.src("./build/package/typeorm-browser.js")
.pipe(uglify())
.pipe(rename("typeorm-browser.min.js"))
.pipe(gulp.dest("./build/package"));
}

@Task()
browserClearPackageDirectory(cb: Function) {
return del([
"./build/systemjs/**"
"./build/browser/**"
]);
}

Expand Down Expand Up @@ -264,9 +217,9 @@ export class Gulpfile {
package() {
return [
"clean",
["browserCopySources", "browserCopyMainBrowserFile", "browserCopyPlatformTools"],
["packageCompile", "browserCompile", "browserCompileSystemJS"],
["packageMoveCompiledFiles", "browserUglify"],
["browserCopySources", "browserCopyPlatformTools"],
["packageCompile", "browserCompile"],
"packageMoveCompiledFiles",
[
"browserClearPackageDirectory",
"packageClearPackageDirectory",
Expand Down

0 comments on commit 0d9fa2f

Please sign in to comment.