Skip to content

Commit

Permalink
added basic sqlite driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Umed Khudoiberdiev committed Sep 2, 2016
1 parent 7fc08ac commit 333c212
Show file tree
Hide file tree
Showing 52 changed files with 1,372 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build/
coverage/
node_modules/
typings/
coverage/
npm-debug.log
config/parameters.json
18 changes: 12 additions & 6 deletions config/parameters.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
{
"connections": {
"mysql": {
"host": "192.168.99.100",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "admin",
"database": "test"
},
"mysqlSecondary": {
"host": "192.168.99.100",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "admin",
"database": "test2"
},
"mariadb": {
"host": "192.168.99.100",
"host": "localhost",
"port": 3307,
"username": "root",
"password": "admin",
"database": "test"
},
"mariadbSecondary": {
"host": "192.168.99.100",
"host": "localhost",
"port": 3307,
"username": "root",
"password": "admin",
"database": "test2"
},
"sqlite": {
"storage": "temp/sqlitedb.db"
},
"sqliteSecondary": {
"storage": "temp/sqlitedb-secondary.db"
},
"postgres": {
"host": "192.168.99.100",
"host": "localhost",
"port": 5432,
"username": "root",
"password": "admin",
"database": "test"
},
"postgresSecondary": {
"host": "192.168.99.100",
"host": "localhost",
"port": 5432,
"username": "root",
"password": "admin",
Expand Down
6 changes: 6 additions & 0 deletions config/parameters.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"password": "admin",
"database": "test2"
},
"sqlite": {
"storage": "temp/sqlitedb.db"
},
"sqliteSecondary": {
"storage": "temp/sqlitedb-secondary.db"
},
"postgres": {
"host": "localhost",
"port": 5432,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
"gulpclass": "0.1.1",
"mariasql": "^0.2.6",
"mocha": "^3.0.1",
"mssql": "^3.3.0",
"mysql": "^2.11.1",
"pg": "^6.0.3",
"remap-istanbul": "^0.6.4",
"sinon": "^1.17.5",
"sinon-chai": "^2.8.0",
"sqlite3": "^3.1.4",
"ts-node": "^1.2.2",
"tslint": "next",
"tslint-stylish": "^2.1.0-beta",
Expand Down
4 changes: 2 additions & 2 deletions sample/sample1-simple-entity/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Post} from "./entity/Post";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand All @@ -17,7 +17,7 @@ const options: ConnectionOptions = {
/*const options: CreateConnectionOptions = {
driver: "postgres",
driverOptions: {
host: "192.168.99.100",
host: "localhost",
port: 5432,
username: "test",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample10-mixed/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Category} from "./entity/Category";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample11-all-types-entity/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {EverythingEntity} from "./entity/EverythingEntity";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample12-custom-naming-strategy/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {CustomNamingStrategy} from "./naming-strategy/CustomNamingStrategy";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample13-everywhere-abstraction/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Blog} from "./entity/Blog";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample14-errors-in-wrong-metdata/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {PostAuthor} from "./entity/PostAuthor";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample15-we-are-reactive/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Post} from "./entity/Post";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample16-indexes/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Post} from "./entity/Post";
const options: ConnectionOptions = {
driver: {
type: "postgres",
host: "192.168.99.100",
host: "localhost",
port: 5432,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample17-versioning/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Post} from "./entity/Post";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample18-lazy-relations/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Category} from "./entity/Category";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample19-one-side-relations/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {PostMetadata} from "./entity/PostMetadata";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample2-one-to-one/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {PostAuthor} from "./entity/PostAuthor";
const options: ConnectionOptions = {
driver: {
type: "postgres",
host: "192.168.99.100",
host: "localhost",
port: 5432,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample20-join-without-relation/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Category} from "./entity/Category";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample21-custom-join-table-column/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Category} from "./entity/Category";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample22-closure-table/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Category} from "./entity/Category";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample23-nested-joins/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Category} from "./entity/Category";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample24-schemas/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Post} from "./entity/Post";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample25-insert-from-inverse-side/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Author} from "./entity/Author";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample26-embedded-tables/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Counters} from "./entity/Counters";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample3-many-to-one/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {PostAuthor} from "./entity/PostAuthor";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
5 changes: 4 additions & 1 deletion sample/sample4-many-to-many/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import {PostDetails} from "./entity/PostDetails";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
database: "test"
},
logging: {
logQueries: true
},
autoSchemaCreate: true,
entityDirectories: [__dirname + "/entity/*"]
};
Expand Down
2 changes: 1 addition & 1 deletion sample/sample5-subscribers/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {EverythingSubscriber} from "./subscriber/EverythingSubscriber";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample6-abstract-table/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Blog} from "./entity/Blog";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample7-pagination/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {PostAuthor} from "./entity/PostAuthor";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample8-self-referencing/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Category} from "./entity/Category";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion sample/sample9-entity-listeners/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {PostAuthor} from "./entity/PostAuthor";
const options: ConnectionOptions = {
driver: {
type: "mysql",
host: "192.168.99.100",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
Expand Down
2 changes: 1 addition & 1 deletion src/connection/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class Connection {
if (dropBeforeSync)
await this.dropDatabase();

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

Expand Down
3 changes: 3 additions & 0 deletions src/connection/ConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {PostgresDriver} from "../driver/postgres/PostgresDriver";
import {AlreadyHasActiveConnectionError} from "./error/AlreadyHasActiveConnectionError";
import {Logger} from "../logger/Logger";
import {MariaDbDriver} from "../driver/mariadb/MariaDbDriver";
import {SqliteDriver} from "../driver/sqlite/SqliteDriver";

/**
* Connection manager holds all connections made to the databases and providers helper management functions
Expand Down Expand Up @@ -120,6 +121,8 @@ export class ConnectionManager {
return new PostgresDriver(options, logger);
case "mariadb":
return new MariaDbDriver(options, logger);
case "sqlite":
return new SqliteDriver(options, logger);
default:
throw new MissingDriverError(options.type);
}
Expand Down
16 changes: 14 additions & 2 deletions src/decorator/columns/Column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@ import {ColumnMetadataArgs} from "../../metadata-args/ColumnMetadataArgs";
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
* decorator will be persisted to the database when entity be saved.
*/
export function Column(options?: ColumnOptions): Function;
export function Column(): Function;

/**
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
* decorator will be persisted to the database when entity be saved.
*/
export function Column(type?: ColumnType, options?: ColumnOptions): Function;
export function Column(type: ColumnType): Function;

/**
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
* decorator will be persisted to the database when entity be saved.
*/
export function Column(options: ColumnOptions): Function;

/**
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
* decorator will be persisted to the database when entity be saved.
*/
export function Column(type: ColumnType, options: ColumnOptions): Function;

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

0 comments on commit 333c212

Please sign in to comment.