This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from eugene-manuilov/develop
Develop changes
- Loading branch information
Showing
27 changed files
with
3,908 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
exports.env = { | ||
es2020: true, | ||
node: true, | ||
jest: true, | ||
}; | ||
|
||
exports.parser = '@typescript-eslint/parser'; | ||
exports.parserOptions = { | ||
ecmaVersion: 11, | ||
sourceType: 'module' | ||
}; | ||
|
||
exports.extends = [ | ||
'standard', | ||
]; | ||
|
||
exports.plugins = [ | ||
'@typescript-eslint', | ||
]; | ||
|
||
exports.rules = { | ||
'@typescript-eslint/no-unused-vars': [ 'error' ], | ||
'array-bracket-spacing': [ 'error', 'always' ], | ||
'comma-dangle': [ 'error', { arrays: 'always-multiline', objects: 'always-multiline' } ], | ||
'indent': [ 'error', 'tab', { SwitchCase: 1 } ], | ||
'no-console': 'error', | ||
'no-tabs': 'off', | ||
'no-unused-vars': 'off', | ||
'no-useless-constructor': 'off', | ||
'padded-blocks': [ 'error', { classes: 'always' } ], | ||
'semi': [ 'error', 'always' ], | ||
'space-before-function-paren': [ 'error', { named: 'never' } ], | ||
'space-in-parens': [ 'error', 'always' ], | ||
'template-curly-spacing': [ 'error', 'always' ], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/node_modules/ | ||
/lib/ | ||
/examples/**/node_modules/ | ||
/examples/**/*.js | ||
/examples/**/*.js.map | ||
/tsconfig.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Build Project", | ||
"type": "shell", | ||
"command": "npm", | ||
"args": ["run", "build"], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,48 @@ | ||
# Changelog | ||
|
||
## v1.2.1 (2020-06-18) | ||
## [Unreleased] - TBD | ||
- | ||
|
||
## [v1.3.0] (2020-11-12) | ||
- Added an example with a shopping cart database. | ||
- Updated builder to throw an error if no entities have been found. | ||
- Updated builder to use entities instead of classes. | ||
- Updated builder to use entity relationships. | ||
- Fixed issues when the absolute path to the config file was used. | ||
- Fixed issues with foreign keys when sometimes foreign keys were defined before referencing tables. | ||
|
||
## [v1.2.1] (2020-06-18) | ||
- Fixed puml diagram downloading issue. | ||
|
||
## v1.2.0 (2020-06-18) | ||
## [v1.2.0] (2020-06-18) | ||
- Added GitHub Actions to check build process on push. | ||
- Added GitHub Actions to check generated UML. | ||
- Added puml format that displays generated UML code. | ||
- Reworked typeorm configuration read to skip connecting to the database. | ||
- Fixed primary column formatting for TXT format (removed HTML tag). | ||
|
||
## v1.1.3 (2020-05-25) | ||
## [v1.1.3] (2020-05-25) | ||
- Fixed typo in the readme file. | ||
- Updated dependencies to the latest versions. | ||
|
||
## v1.1.2 (2020-01-11) | ||
## [v1.1.2] (2020-01-11) | ||
- Fixed UML generation issue. | ||
|
||
## v1.1.1 (2020-01-11) | ||
## [v1.1.1] (2020-01-11) | ||
|
||
- Fixed build command issue. | ||
|
||
## v1.1.0 (2020-01-11) | ||
## [v1.1.0] (2020-01-11) | ||
|
||
- Added `--download` option to download a diagram. | ||
- Added `--include` option to include only specific entities to the diagram. | ||
- Added `--exclude` option to exclude specific entities from the diagram. | ||
|
||
[Unreleased]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.3.0...master | ||
[v1.3.0]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.2.1...v1.3.0 | ||
[v1.2.1]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.2.0...v1.2.1 | ||
[v1.2.0]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.1.3...v1.2.0 | ||
[v1.1.3]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.1.2...v1.1.3 | ||
[v1.1.2]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.1.1...v1.1.2 | ||
[v1.1.1]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.1.0...v1.1.1 | ||
[v1.1.0]: https://github.com/eugene-manuilov/typeorm-uml/releases/tag/v1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Shopping Cart Database | ||
|
||
The Shopping Cart Database in MySQL as the starting point to develop the online shopping cart websites and applications. | ||
|
||
## Database Schema | ||
|
||
The visual database design of the Shopping Cart Database is shown below: | ||
|
||
[![shopping cart example](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tutorials24x7/shopping-cart-database-mysql](https://github.com/tutorials24x7/shopping-cart-database-mysql) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { | ||
Column, | ||
Entity, | ||
Index, | ||
JoinColumn, | ||
ManyToOne, | ||
OneToMany, | ||
PrimaryGeneratedColumn | ||
} from 'typeorm'; | ||
|
||
import { User } from './User'; | ||
import { CartItem } from './CartItem'; | ||
|
||
@Index( 'idx_cart_user', [ 'userId' ], {} ) | ||
@Entity( 'cart', { schema: 'shop' } ) | ||
export class Cart { | ||
|
||
@PrimaryGeneratedColumn( { type: 'bigint', name: 'id' } ) | ||
id: string; | ||
|
||
@Column( 'bigint', { name: 'userId', nullable: true } ) | ||
userId: string | null; | ||
|
||
@Column( 'varchar', { name: 'sessionId', length: 100 } ) | ||
sessionId: string; | ||
|
||
@Column( 'varchar', { name: 'token', length: 100 } ) | ||
token: string; | ||
|
||
@Column( 'smallint', { name: 'status', default: () => "'0'" } ) | ||
status: number; | ||
|
||
@Column( 'varchar', { name: 'firstName', nullable: true, length: 50 } ) | ||
firstName: string | null; | ||
|
||
@Column( 'varchar', { name: 'middleName', nullable: true, length: 50 } ) | ||
middleName: string | null; | ||
|
||
@Column( 'varchar', { name: 'lastName', nullable: true, length: 50 } ) | ||
lastName: string | null; | ||
|
||
@Column( 'varchar', { name: 'mobile', nullable: true, length: 15 } ) | ||
mobile: string | null; | ||
|
||
@Column( 'varchar', { name: 'email', nullable: true, length: 50 } ) | ||
email: string | null; | ||
|
||
@Column( 'varchar', { name: 'line1', nullable: true, length: 50 } ) | ||
line1: string | null; | ||
|
||
@Column( 'varchar', { name: 'line2', nullable: true, length: 50 } ) | ||
line2: string | null; | ||
|
||
@Column( 'varchar', { name: 'city', nullable: true, length: 50 } ) | ||
city: string | null; | ||
|
||
@Column( 'varchar', { name: 'province', nullable: true, length: 50 } ) | ||
province: string | null; | ||
|
||
@Column( 'varchar', { name: 'country', nullable: true, length: 50 } ) | ||
country: string | null; | ||
|
||
@Column( 'datetime', { name: 'createdAt' } ) | ||
createdAt: Date; | ||
|
||
@Column( 'datetime', { name: 'updatedAt', nullable: true } ) | ||
updatedAt: Date | null; | ||
|
||
@Column( 'text', { name: 'content', nullable: true } ) | ||
content: string | null; | ||
|
||
@ManyToOne( () => User, ( user ) => user.carts, { | ||
onDelete: 'RESTRICT', | ||
onUpdate: 'RESTRICT', | ||
} ) | ||
@JoinColumn( [ { name: 'userId', referencedColumnName: 'id' } ] ) | ||
user: User; | ||
|
||
@OneToMany( () => CartItem, ( cartItem ) => cartItem.cart ) | ||
cartItems: CartItem[]; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { | ||
Column, | ||
Entity, | ||
Index, | ||
JoinColumn, | ||
ManyToOne, | ||
PrimaryGeneratedColumn | ||
} from 'typeorm'; | ||
|
||
import { Cart } from './Cart'; | ||
import { Product } from './Product'; | ||
|
||
@Index( 'idx_cart_item_product', [ 'productId' ], {} ) | ||
@Index( 'idx_cart_item_cart', [ 'cartId' ], {} ) | ||
@Entity( 'cart_item', { schema: 'shop' } ) | ||
export class CartItem { | ||
|
||
@PrimaryGeneratedColumn( { type: 'bigint', name: 'id' } ) | ||
id: string; | ||
|
||
@Column( 'bigint', { name: 'productId' } ) | ||
productId: string; | ||
|
||
@Column( 'bigint', { name: 'cartId' } ) | ||
cartId: string; | ||
|
||
@Column( 'varchar', { name: 'sku', length: 100 } ) | ||
sku: string; | ||
|
||
@Column( 'float', { name: 'price', precision: 12, default: () => "'0'" } ) | ||
price: number; | ||
|
||
@Column( 'float', { name: 'discount', precision: 12, default: () => "'0'" } ) | ||
discount: number; | ||
|
||
@Column( 'smallint', { name: 'quantity', default: () => "'0'" } ) | ||
quantity: number; | ||
|
||
@Column( 'tinyint', { name: 'active', width: 1, default: () => "'0'" } ) | ||
active: boolean; | ||
|
||
@Column( 'datetime', { name: 'createdAt' } ) | ||
createdAt: Date; | ||
|
||
@Column( 'datetime', { name: 'updatedAt', nullable: true } ) | ||
updatedAt: Date | null; | ||
|
||
@Column( 'text', { name: 'content', nullable: true } ) | ||
content: string | null; | ||
|
||
@ManyToOne( () => Cart, ( cart ) => cart.cartItems, { | ||
onDelete: 'RESTRICT', | ||
onUpdate: 'RESTRICT', | ||
} ) | ||
@JoinColumn( [ { name: 'cartId', referencedColumnName: 'id' } ] ) | ||
cart: Cart; | ||
|
||
@ManyToOne( () => Product, ( product ) => product.cartItems, { | ||
onDelete: 'RESTRICT', | ||
onUpdate: 'RESTRICT', | ||
} ) | ||
@JoinColumn( [ { name: 'productId', referencedColumnName: 'id' } ] ) | ||
product: Product; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
Column, | ||
Entity, | ||
Index, | ||
JoinColumn, | ||
JoinTable, | ||
ManyToMany, | ||
ManyToOne, | ||
OneToMany, | ||
PrimaryGeneratedColumn | ||
} from 'typeorm'; | ||
|
||
import { Product } from './Product'; | ||
|
||
@Index( 'idx_category_parent', [ 'parentId' ], {} ) | ||
@Entity( 'category', { schema: 'shop' } ) | ||
export class Category { | ||
|
||
@PrimaryGeneratedColumn( { type: 'bigint', name: 'id' } ) | ||
id: string; | ||
|
||
@Column( 'bigint', { name: 'parentId', nullable: true } ) | ||
parentId: string | null; | ||
|
||
@Column( 'varchar', { name: 'title', length: 75 } ) | ||
title: string; | ||
|
||
@Column( 'varchar', { name: 'metaTitle', nullable: true, length: 100 } ) | ||
metaTitle: string | null; | ||
|
||
@Column( 'varchar', { name: 'slug', length: 100 } ) | ||
slug: string; | ||
|
||
@Column( 'text', { name: 'content', nullable: true } ) | ||
content: string | null; | ||
|
||
@ManyToOne( () => Category, ( category ) => category.categories, { | ||
onDelete: 'RESTRICT', | ||
onUpdate: 'RESTRICT', | ||
} ) | ||
@JoinColumn( [ { name: 'parentId', referencedColumnName: 'id' } ] ) | ||
parent: Category; | ||
|
||
@OneToMany( () => Category, ( category ) => category.parent ) | ||
categories: Category[]; | ||
|
||
@ManyToMany( () => Product, ( product ) => product.categories ) | ||
@JoinTable( { | ||
name: 'product_category', | ||
joinColumns: [ { name: 'categoryId', referencedColumnName: 'id' } ], | ||
inverseJoinColumns: [ { name: 'productId', referencedColumnName: 'id' } ], | ||
schema: 'shop', | ||
} ) | ||
products: Product[]; | ||
|
||
} |
Oops, something went wrong.