mjs-mysql-builder
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "mjs-mysql-builder", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Mysql query builder", | ||
"main": "index.mjs", | ||
"scripts": { | ||
"test": "ms test", | ||
"test": "npm run build && ms test", | ||
"build": "flow-remove-types src/ -d build/", | ||
@@ -9,0 +9,0 @@ "lint:check": "eslint ./ --ext .mjs", |
@@ -43,5 +43,7 @@ ## Mysql query builder | ||
.add('email', f => f.type('varchar(50)').notNull().unique()) | ||
.add('name', f => f.type('varchar(50)').nullable()) | ||
.add('name', f => f.type('varchar(50)').null()) | ||
.add('currency', f => f.enum('RUB', 'USD', 'EUR').notNull().default('RUB')) | ||
.add('type', f => f.type('varchar(30)').index().using(INDEX_TYPES.BTREE)) | ||
.add('book_id', f => f.type('int(11)').notNull().foreign().references('books', 'id').onDelete(REFERENCE_OPTIONS.CASCADE)) | ||
.key('currency', 'type').unique().using(INDEX_TYPES.HASH) | ||
/* You can get Schema string */ | ||
@@ -53,2 +55,18 @@ .build() // -> string | ||
- This converts to | ||
```sql | ||
CREATE TABLE IF NOT EXISTS `users` ( | ||
`id` int(11) AUTO_INCREMENT NOT NULL ,PRIMARY KEY (`id`) , | ||
`email` varchar(50) NOT NULL UNIQUE , | ||
`name` varchar(50) NULL , | ||
`currency` enum('RUB', 'USD', 'EUR') NOT NULL DEFAULT 'RUB' , | ||
`type` varchar(30) , | ||
INDEX (`type`) USING BTREE , | ||
`book_id` int(11) NOT NULL , | ||
FOREIGN KEY (`book_id`) REFERENCES `books` (`id`) ON DELETE CASCADE , | ||
UNIQUE KEY (`currency`, `type`) USING HASH | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci | ||
``` | ||
- Query builder | ||
@@ -55,0 +73,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46992
1193
138