Skip to content

Commit 333c212

Browse files
author
Umed Khudoiberdiev
committed
added basic sqlite driver
1 parent 7fc08ac commit 333c212

File tree

52 files changed

+1372
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1372
-229
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
build/
2+
coverage/
23
node_modules/
34
typings/
4-
coverage/
55
npm-debug.log
66
config/parameters.json

config/parameters.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
11
{
22
"connections": {
33
"mysql": {
4-
"host": "192.168.99.100",
4+
"host": "localhost",
55
"port": 3306,
66
"username": "root",
77
"password": "admin",
88
"database": "test"
99
},
1010
"mysqlSecondary": {
11-
"host": "192.168.99.100",
11+
"host": "localhost",
1212
"port": 3306,
1313
"username": "root",
1414
"password": "admin",
1515
"database": "test2"
1616
},
1717
"mariadb": {
18-
"host": "192.168.99.100",
18+
"host": "localhost",
1919
"port": 3307,
2020
"username": "root",
2121
"password": "admin",
2222
"database": "test"
2323
},
2424
"mariadbSecondary": {
25-
"host": "192.168.99.100",
25+
"host": "localhost",
2626
"port": 3307,
2727
"username": "root",
2828
"password": "admin",
2929
"database": "test2"
3030
},
31+
"sqlite": {
32+
"storage": "temp/sqlitedb.db"
33+
},
34+
"sqliteSecondary": {
35+
"storage": "temp/sqlitedb-secondary.db"
36+
},
3137
"postgres": {
32-
"host": "192.168.99.100",
38+
"host": "localhost",
3339
"port": 5432,
3440
"username": "root",
3541
"password": "admin",
3642
"database": "test"
3743
},
3844
"postgresSecondary": {
39-
"host": "192.168.99.100",
45+
"host": "localhost",
4046
"port": 5432,
4147
"username": "root",
4248
"password": "admin",

config/parameters.json.dist

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"password": "admin",
1515
"database": "test2"
1616
},
17+
"sqlite": {
18+
"storage": "temp/sqlitedb.db"
19+
},
20+
"sqliteSecondary": {
21+
"storage": "temp/sqlitedb-secondary.db"
22+
},
1723
"postgres": {
1824
"host": "localhost",
1925
"port": 5432,

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343
"gulpclass": "0.1.1",
4444
"mariasql": "^0.2.6",
4545
"mocha": "^3.0.1",
46+
"mssql": "^3.3.0",
4647
"mysql": "^2.11.1",
4748
"pg": "^6.0.3",
4849
"remap-istanbul": "^0.6.4",
4950
"sinon": "^1.17.5",
5051
"sinon-chai": "^2.8.0",
52+
"sqlite3": "^3.1.4",
5153
"ts-node": "^1.2.2",
5254
"tslint": "next",
5355
"tslint-stylish": "^2.1.0-beta",

sample/sample1-simple-entity/app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Post} from "./entity/Post";
55
const options: ConnectionOptions = {
66
driver: {
77
type: "mysql",
8-
host: "192.168.99.100",
8+
host: "localhost",
99
port: 3306,
1010
username: "root",
1111
password: "admin",
@@ -17,7 +17,7 @@ const options: ConnectionOptions = {
1717
/*const options: CreateConnectionOptions = {
1818
driver: "postgres",
1919
driverOptions: {
20-
host: "192.168.99.100",
20+
host: "localhost",
2121
port: 5432,
2222
username: "test",
2323
password: "admin",

sample/sample10-mixed/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Category} from "./entity/Category";
99
const options: ConnectionOptions = {
1010
driver: {
1111
type: "mysql",
12-
host: "192.168.99.100",
12+
host: "localhost",
1313
port: 3306,
1414
username: "root",
1515
password: "admin",

sample/sample11-all-types-entity/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {EverythingEntity} from "./entity/EverythingEntity";
55
const options: ConnectionOptions = {
66
driver: {
77
type: "mysql",
8-
host: "192.168.99.100",
8+
host: "localhost",
99
port: 3306,
1010
username: "root",
1111
password: "admin",

sample/sample12-custom-naming-strategy/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {CustomNamingStrategy} from "./naming-strategy/CustomNamingStrategy";
66
const options: ConnectionOptions = {
77
driver: {
88
type: "mysql",
9-
host: "192.168.99.100",
9+
host: "localhost",
1010
port: 3306,
1111
username: "root",
1212
password: "admin",

sample/sample13-everywhere-abstraction/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {Blog} from "./entity/Blog";
88
const options: ConnectionOptions = {
99
driver: {
1010
type: "mysql",
11-
host: "192.168.99.100",
11+
host: "localhost",
1212
port: 3306,
1313
username: "root",
1414
password: "admin",

sample/sample14-errors-in-wrong-metdata/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {PostAuthor} from "./entity/PostAuthor";
66
const options: ConnectionOptions = {
77
driver: {
88
type: "mysql",
9-
host: "192.168.99.100",
9+
host: "localhost",
1010
port: 3306,
1111
username: "root",
1212
password: "admin",

sample/sample15-we-are-reactive/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Post} from "./entity/Post";
55
const options: ConnectionOptions = {
66
driver: {
77
type: "mysql",
8-
host: "192.168.99.100",
8+
host: "localhost",
99
port: 3306,
1010
username: "root",
1111
password: "admin",

sample/sample16-indexes/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Post} from "./entity/Post";
55
const options: ConnectionOptions = {
66
driver: {
77
type: "postgres",
8-
host: "192.168.99.100",
8+
host: "localhost",
99
port: 5432,
1010
username: "root",
1111
password: "admin",

sample/sample17-versioning/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Post} from "./entity/Post";
55
const options: ConnectionOptions = {
66
driver: {
77
type: "mysql",
8-
host: "192.168.99.100",
8+
host: "localhost",
99
port: 3306,
1010
username: "root",
1111
password: "admin",

sample/sample18-lazy-relations/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Category} from "./entity/Category";
77
const options: ConnectionOptions = {
88
driver: {
99
type: "mysql",
10-
host: "192.168.99.100",
10+
host: "localhost",
1111
port: 3306,
1212
username: "root",
1313
password: "admin",

sample/sample19-one-side-relations/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {PostMetadata} from "./entity/PostMetadata";
88
const options: ConnectionOptions = {
99
driver: {
1010
type: "mysql",
11-
host: "192.168.99.100",
11+
host: "localhost",
1212
port: 3306,
1313
username: "root",
1414
password: "admin",

sample/sample2-one-to-one/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {PostAuthor} from "./entity/PostAuthor";
1111
const options: ConnectionOptions = {
1212
driver: {
1313
type: "postgres",
14-
host: "192.168.99.100",
14+
host: "localhost",
1515
port: 5432,
1616
username: "root",
1717
password: "admin",

sample/sample20-join-without-relation/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Category} from "./entity/Category";
77
const options: ConnectionOptions = {
88
driver: {
99
type: "mysql",
10-
host: "192.168.99.100",
10+
host: "localhost",
1111
port: 3306,
1212
username: "root",
1313
password: "admin",

sample/sample21-custom-join-table-column/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Category} from "./entity/Category";
77
const options: ConnectionOptions = {
88
driver: {
99
type: "mysql",
10-
host: "192.168.99.100",
10+
host: "localhost",
1111
port: 3306,
1212
username: "root",
1313
password: "admin",

sample/sample22-closure-table/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Category} from "./entity/Category";
55
const options: ConnectionOptions = {
66
driver: {
77
type: "mysql",
8-
host: "192.168.99.100",
8+
host: "localhost",
99
port: 3306,
1010
username: "root",
1111
password: "admin",

sample/sample23-nested-joins/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Category} from "./entity/Category";
77
const options: ConnectionOptions = {
88
driver: {
99
type: "mysql",
10-
host: "192.168.99.100",
10+
host: "localhost",
1111
port: 3306,
1212
username: "root",
1313
password: "admin",

sample/sample24-schemas/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Post} from "./entity/Post";
77
const options: ConnectionOptions = {
88
driver: {
99
type: "mysql",
10-
host: "192.168.99.100",
10+
host: "localhost",
1111
port: 3306,
1212
username: "root",
1313
password: "admin",

sample/sample25-insert-from-inverse-side/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Author} from "./entity/Author";
66
const options: ConnectionOptions = {
77
driver: {
88
type: "mysql",
9-
host: "192.168.99.100",
9+
host: "localhost",
1010
port: 3306,
1111
username: "root",
1212
password: "admin",

sample/sample26-embedded-tables/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Counters} from "./entity/Counters";
77
const options: ConnectionOptions = {
88
driver: {
99
type: "mysql",
10-
host: "192.168.99.100",
10+
host: "localhost",
1111
port: 3306,
1212
username: "root",
1313
password: "admin",

sample/sample3-many-to-one/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {PostAuthor} from "./entity/PostAuthor";
1111
const options: ConnectionOptions = {
1212
driver: {
1313
type: "mysql",
14-
host: "192.168.99.100",
14+
host: "localhost",
1515
port: 3306,
1616
username: "root",
1717
password: "admin",

sample/sample4-many-to-many/app.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import {PostDetails} from "./entity/PostDetails";
66
const options: ConnectionOptions = {
77
driver: {
88
type: "mysql",
9-
host: "192.168.99.100",
9+
host: "localhost",
1010
port: 3306,
1111
username: "root",
1212
password: "admin",
1313
database: "test"
1414
},
15+
logging: {
16+
logQueries: true
17+
},
1518
autoSchemaCreate: true,
1619
entityDirectories: [__dirname + "/entity/*"]
1720
};

sample/sample5-subscribers/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {EverythingSubscriber} from "./subscriber/EverythingSubscriber";
99
const options: ConnectionOptions = {
1010
driver: {
1111
type: "mysql",
12-
host: "192.168.99.100",
12+
host: "localhost",
1313
port: 3306,
1414
username: "root",
1515
password: "admin",

sample/sample6-abstract-table/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {Blog} from "./entity/Blog";
88
const options: ConnectionOptions = {
99
driver: {
1010
type: "mysql",
11-
host: "192.168.99.100",
11+
host: "localhost",
1212
port: 3306,
1313
username: "root",
1414
password: "admin",

sample/sample7-pagination/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {PostAuthor} from "./entity/PostAuthor";
77
const options: ConnectionOptions = {
88
driver: {
99
type: "mysql",
10-
host: "192.168.99.100",
10+
host: "localhost",
1111
port: 3306,
1212
username: "root",
1313
password: "admin",

sample/sample8-self-referencing/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Category} from "./entity/Category";
55
const options: ConnectionOptions = {
66
driver: {
77
type: "mysql",
8-
host: "192.168.99.100",
8+
host: "localhost",
99
port: 3306,
1010
username: "root",
1111
password: "admin",

sample/sample9-entity-listeners/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {PostAuthor} from "./entity/PostAuthor";
77
const options: ConnectionOptions = {
88
driver: {
99
type: "mysql",
10-
host: "192.168.99.100",
10+
host: "localhost",
1111
port: 3306,
1212
username: "root",
1313
password: "admin",

src/connection/Connection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export class Connection {
235235
if (dropBeforeSync)
236236
await this.dropDatabase();
237237

238-
const schemaCreator = new SchemaBuilder(this.driver, this.entityMetadatas); // todo: use factory there later
238+
const schemaCreator = new SchemaBuilder(this.driver, this.entityMetadatas, this.createNamingStrategy()); // todo: use factory there later
239239
await schemaCreator.create();
240240
}
241241

src/connection/ConnectionManager.ts

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {PostgresDriver} from "../driver/postgres/PostgresDriver";
99
import {AlreadyHasActiveConnectionError} from "./error/AlreadyHasActiveConnectionError";
1010
import {Logger} from "../logger/Logger";
1111
import {MariaDbDriver} from "../driver/mariadb/MariaDbDriver";
12+
import {SqliteDriver} from "../driver/sqlite/SqliteDriver";
1213

1314
/**
1415
* Connection manager holds all connections made to the databases and providers helper management functions
@@ -120,6 +121,8 @@ export class ConnectionManager {
120121
return new PostgresDriver(options, logger);
121122
case "mariadb":
122123
return new MariaDbDriver(options, logger);
124+
case "sqlite":
125+
return new SqliteDriver(options, logger);
123126
default:
124127
throw new MissingDriverError(options.type);
125128
}

src/decorator/columns/Column.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@ import {ColumnMetadataArgs} from "../../metadata-args/ColumnMetadataArgs";
99
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
1010
* decorator will be persisted to the database when entity be saved.
1111
*/
12-
export function Column(options?: ColumnOptions): Function;
12+
export function Column(): Function;
1313

1414
/**
1515
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
1616
* decorator will be persisted to the database when entity be saved.
1717
*/
18-
export function Column(type?: ColumnType, options?: ColumnOptions): Function;
18+
export function Column(type: ColumnType): Function;
19+
20+
/**
21+
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
22+
* decorator will be persisted to the database when entity be saved.
23+
*/
24+
export function Column(options: ColumnOptions): Function;
25+
26+
/**
27+
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
28+
* decorator will be persisted to the database when entity be saved.
29+
*/
30+
export function Column(type: ColumnType, options: ColumnOptions): Function;
1931

2032
/**
2133
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this

0 commit comments

Comments
 (0)