Gathering detailed insights and metrics for selfclose-sql-schematic
Gathering detailed insights and metrics for selfclose-sql-schematic
Gathering detailed insights and metrics for selfclose-sql-schematic
Gathering detailed insights and metrics for selfclose-sql-schematic
NodeJS modules is mysql schematic builder, or create table if not exists helper
npm install selfclose-sql-schematic
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
22 Commits
1 Branches
1 Contributors
Updated on Mar 13, 2019
Latest Version
1.0.9
Package Id
selfclose-sql-schematic@1.0.9
Unpacked Size
17.42 kB
Size
4.93 kB
File Count
7
NPM Version
6.8.0
Node Version
10.15.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
NodeJS modules is mysql schematic builder, or create table if not exists helper
This package
npm i --save selfclose-sql-schematic
This quick example shows how it's looks and usage.
1const schema = require('selfclose-sql-schematic'); 2var s = schema.createTableIfNotExist('post', { 3 comment: 'this is post table' 4}); 5s.add('enabled').type(schema.type.TINYINT, 4).notNull().default(1); 6s.add('title').type(schema.type.VARCHAR, 60).notNull(); 7s.add('type').type(schema.type.VARCHAR, 60).notNull().default('post'); 8s.add('money').type(T.DECIMAL, [10,2]).notNull(); 9s.add('permalink').type(schema.type.VARCHAR, 120).notNull().unique(); 10console.log('MYSQL', s.toString());
And You'll get
1CREATE TABLE IF NOT EXISTS `post` (`id` INT NOT NULL AUTO_INCREMENT, `enabled` TINYINT(4) NOT NULL DEFAULT 1, `title` VARCHAR(60) NOT NULL, `type` VARCHAR(60) NOT NULL DEFAULT 'post', `permalink` VARCHAR(120) NOT NULL, `created_at` DATETIME NOT NULL, 2`updated_at` DATETIME NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `permalink` (`permalink`)) COMMENT='this is post table' COLLATE='utf8_general_ci' ENGINE=InnoDB
Then, Take these query string to mysql query function
sql.query(s.toString());
First create variable
1var schema = FunctionHere()
(Values as shown is default)
1{ 2 comment: '', 3 id: true, //Auto create id column with auto increment and primary key 4 timestamp: true, //Auto create 'created_at' and 'updated_at' 5 timestamp_type: 'DATETIME', // type can be 'DATETIME' or 'NUMBER' 6 charset: 'utf8_general_ci', 7 engine: 'InnoDB' 8}
Next will be chain functions
Most of theme already mysql syntax
Add with Object, With this define you will be easier to reuse variable later
1const schema = require('selfclose-sql-schematic'); 2var s = schema.createTableIfNotExist('post', { 3 comment: 'this is post table' 4}); 5let model = { 6 enabled: { 7 type: T.TINYINT, 8 length: 4, 9 notNull: true, 10 default: 1 11 }, 12 title: { 13 type: T.VARCHAR, 14 length: 60, 15 notNull: true, 16 regex: /^[a-zA-Z]{10,60}$/ //This is not Module's variable, But can be use later 17 }, 18 type: { 19 type: T.VARCHAR, 20 length: 60, 21 notNull: true, 22 default: 'post' 23 }, 24 permalink: { 25 type: T.VARCHAR, 26 length: 120, 27 notNull: true, 28 unique: true 29 }, 30}; 31s.add(model); 32console.log('MYSQL', s.toString()); 33 34//Reuse variable 35let _title = 'HELLO!'; 36if (_title.length > model.title.length) { 37 console.log('-- Title is too long') 38} 39if (!model.title.regex.test(_title)) { 40 console.log('-- Title must be only English Characters!'); 41}
Chain with .foreignKey(targetTable, targetTableColumn, onDelete, onUpdate)
1const T = schema.type; 2const A = schema.action; 3 4var member = schema.createTableIfNotExist('member', { 5 comment: 'member' 6}); 7member.add('username').type(T.VARCHAR, 50).notNull().unique(); 8member.add('age').type(T.INT, 4).notNull().default(18); 9console.log('MYSQL', member.toString()); 10 11var member_type = schema.createTableIfNotExist('member_type', { 12 comment: 'pair with member' 13}); 14member_type.add('name').type(T.VARCHAR, 20).notNull().unique().foreignKey('member', 'id', A.CASCADE, A.NO_ACTION); 15 16console.log('MYSQL', member_type.toString()); 17
##--WILL CONTINUE WRITE README SOON--
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More