tspace-mysql 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Model = function (model, npm) {
4
- return "import { Model } from '".concat(npm, "'\nclass ").concat(model, " extends Model {\n constructor(){\n super()\n this.useUUID()\n this.useTimestamp()\n }\n}\nexport { ").concat(model, " }\nexport default ").concat(model, "\n");
4
+ return "import { Model } from '".concat(npm, "'\nclass ").concat(model, " extends Model {\n constructor(){\n super()\n /**\n * \n * Assign setting global in your model\n * @useMethod\n *\n * this.useDebug() // => runing a uuid (universally unique identifier) when insert new data\n * this.usePrimaryKey('id') // => runing a uuid (universally unique identifier) when insert new data\n * this.useTimestamp({ createdAt : 'created_at' , updatedAt : 'updated_at' }) // runing a timestamp when insert or update\n * this.useSoftDelete()\n * this.useDisableSoftDeleteInRelations()\n * this.useTable('Users')\n * this.useTableSingular()\n * this.useTablePlural()\n * this.usePattern('snake_case') \n * this.useUUID('uuid')\n * this.useRegistry()\n */\n }\n}\nexport { ").concat(model, " }\nexport default ").concat(model, "\n");
5
5
  };
6
6
  exports.default = Model;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Table = function (table, npm) {
4
- return "import { Schema , Blueprint , DB } from '".concat(npm, "'\n(async () => {\n await new Schema().table('").concat(table, "',{ \n id : new Blueprint().int().notNull().primary().autoIncrement(),\n name : new Blueprint().varchar(120).default('my name'),\n uuid : new Blueprint().varchar(50),\n email : new Blueprint().varchar(120).unique(),\n email_verify : new Blueprint().tinyInt(),\n password : new Blueprint().varchar(120),\n birthdate : new Blueprint().date(),\n created_at : new Blueprint().null().timestamp(),\n updated_at : new Blueprint().null().timestamp()\n })\n\n /**\n * \n * @Faker data\n * await new DB().table('").concat(table, "').faker(5)\n */\n})()\n");
4
+ return "import { Schema , Blueprint , DB } from '".concat(npm, "'\n(async () => {\n await new Schema().table('").concat(table, "',{ \n id : new Blueprint().int().notNull().primary().autoIncrement(),\n uuid : new Blueprint().varchar(50),\n name : new Blueprint().varchar(120).default('my name'),\n email : new Blueprint().varchar(120).unique(),\n email_verify : new Blueprint().tinyInt(),\n password : new Blueprint().varchar(120),\n birthdate : new Blueprint().date(),\n created_at : new Blueprint().null().timestamp(),\n updated_at : new Blueprint().null().timestamp()\n })\n\n /**\n * \n * @Faker data\n * await new DB().table('").concat(table, "').faker(5)\n */\n})()\n");
5
5
  };
6
6
  exports.default = Table;
@@ -4,5 +4,11 @@ declare const env: Readonly<{
4
4
  DB_USERNAME: string | undefined;
5
5
  DB_PASSWORD: string | undefined;
6
6
  DB_DATABASE: string | undefined;
7
+ TSPACE_MYSQL_HOST: string | undefined;
8
+ TSPACE_MYSQL_PORT: string | undefined;
9
+ TSPACE_MYSQL_USERNAME: string | undefined;
10
+ TSPACE_MYSQL_PASSWORD: string | undefined;
11
+ TSPACE_MYSQL_DATABASE: string | undefined;
7
12
  }>;
13
+ export { env };
8
14
  export default env;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.env = void 0;
6
7
  var dotenv_1 = __importDefault(require("dotenv"));
7
8
  var path_1 = __importDefault(require("path"));
8
9
  var fs_1 = __importDefault(require("fs"));
@@ -23,6 +24,12 @@ var env = Object.freeze({
23
24
  DB_PORT: process.env.DB_PORT,
24
25
  DB_USERNAME: process.env.DB_USERNAME,
25
26
  DB_PASSWORD: process.env.DB_PASSWORD,
26
- DB_DATABASE: process.env.DB_DATABASE
27
+ DB_DATABASE: process.env.DB_DATABASE,
28
+ TSPACE_MYSQL_HOST: process.env.TSPACE_MYSQL_HOST,
29
+ TSPACE_MYSQL_PORT: process.env.TSPACE_MYSQL_PORT,
30
+ TSPACE_MYSQL_USERNAME: process.env.TSPACE_MYSQL_USERNAME,
31
+ TSPACE_MYSQL_PASSWORD: process.env.TSPACE_MYSQL_PASSWORD,
32
+ TSPACE_MYSQL_DATABASE: process.env.TSPACE_MYSQL_DATABASE
27
33
  });
34
+ exports.env = env;
28
35
  exports.default = env;
@@ -1,7 +1,19 @@
1
- interface Connection {
1
+ export interface PoolCallback {
2
+ query: (sql: string, callback: (err: any, result: any) => void) => void;
3
+ release: () => void;
4
+ }
5
+ export interface ConnectionTransaction {
6
+ query: (sql: string) => Promise<any[]>;
7
+ startTransaction: () => Promise<any[]>;
8
+ commit: () => Promise<any[]>;
9
+ rollback: () => Promise<any[]>;
10
+ }
11
+ export interface Connection {
2
12
  query: (sql: string) => Promise<any[]>;
13
+ connection: () => Promise<ConnectionTransaction>;
3
14
  }
4
- interface Options {
15
+ export interface Options {
16
+ [key: string]: any;
5
17
  connectionLimit?: number;
6
18
  dateStrings?: boolean;
7
19
  waitForConnections?: boolean;
@@ -12,16 +24,25 @@ interface Options {
12
24
  user: string;
13
25
  password: string;
14
26
  }
15
- declare class PoolConnection {
16
- [x: string]: any;
27
+ export declare class PoolConnection {
17
28
  private OPTIONS;
18
29
  constructor(options?: Options);
19
- private _pool;
20
- private _messageError;
21
- connection(): Connection;
30
+ /**
31
+ *
32
+ * Set a options connection pool
33
+ * @return {this} this
34
+ */
22
35
  options(options: Options): this;
36
+ /**
37
+ *
38
+ * Get a connection pool
39
+ * @return {Connection} Connection
40
+ */
41
+ connection(): Connection;
42
+ private _defaultOptions;
43
+ private _getJsonOptions;
44
+ private _messageError;
23
45
  }
24
46
  declare const Pool: Connection;
25
47
  export { Pool };
26
- export { PoolConnection };
27
48
  export default Pool;
@@ -14,46 +14,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.PoolConnection = exports.Pool = void 0;
17
+ exports.Pool = exports.PoolConnection = void 0;
18
+ var fs_1 = __importDefault(require("fs"));
19
+ var path_1 = __importDefault(require("path"));
20
+ var env_1 = require("../config/env");
18
21
  var mysql_1 = require("mysql");
19
- var env_1 = __importDefault(require("../config/env"));
20
22
  var PoolConnection = /** @class */ (function () {
21
23
  function PoolConnection(options) {
22
- this.OPTIONS = new Map(Object.entries({
23
- connectionLimit: 10,
24
- dateStrings: true,
25
- waitForConnections: false,
26
- charset: 'utf8mb4',
27
- host: String(env_1.default.DB_HOST),
28
- port: Number.isNaN(Number(env_1.default.DB_PORT))
29
- ? 3306
30
- : Number(env_1.default.DB_PORT),
31
- database: String(env_1.default.DB_DATABASE),
32
- user: String(env_1.default.DB_USERNAME),
33
- password: String(env_1.default.DB_PASSWORD)
34
- }));
24
+ this.OPTIONS = this._getJsonOptions();
35
25
  if (options) {
36
26
  this.OPTIONS = new Map(Object.entries(__assign(__assign({}, Object.fromEntries(this.OPTIONS)), JSON.parse(JSON.stringify(options)))));
37
27
  }
38
28
  }
39
- PoolConnection.prototype._pool = function () {
40
- return (0, mysql_1.createPool)(Object.fromEntries(this.OPTIONS));
41
- };
42
- PoolConnection.prototype._messageError = function () {
43
- console.log("\u001B[1m\u001B[31m\n Connection lost to database ! \u001B[0m\n ------------------------------- \u001B[33m\n DB_HOST : ".concat(this.OPTIONS.get('host'), " \n DB_PORT : ").concat(this.OPTIONS.get('port'), " \n DB_DATABASE : ").concat(this.OPTIONS.get('database'), " \n DB_USERNAME : ").concat(this.OPTIONS.get('user'), " \n DB_PASSWORD : ").concat(this.OPTIONS.get('password'), " \u001B[0m \n -------------------------------\n "));
44
- return;
29
+ /**
30
+ *
31
+ * Set a options connection pool
32
+ * @return {this} this
33
+ */
34
+ PoolConnection.prototype.options = function (options) {
35
+ this.OPTIONS = new Map(Object.entries(options));
36
+ return this;
45
37
  };
38
+ /**
39
+ *
40
+ * Get a connection pool
41
+ * @return {Connection} Connection
42
+ */
46
43
  PoolConnection.prototype.connection = function () {
47
44
  var _this = this;
48
- var pool = this._pool();
45
+ var pool = (0, mysql_1.createPool)(Object.fromEntries(this.OPTIONS));
49
46
  pool.getConnection(function (err, connection) {
50
47
  if (err) {
51
- _this._messageError();
52
- return process.exit();
48
+ var message_1 = _this._messageError.bind(_this);
49
+ process.nextTick(function () {
50
+ console.log(message_1());
51
+ return process.exit();
52
+ });
53
53
  }
54
54
  if (connection)
55
55
  connection.release();
56
- return;
57
56
  });
58
57
  return {
59
58
  query: function (sql) {
@@ -64,12 +63,70 @@ var PoolConnection = /** @class */ (function () {
64
63
  return resolve(results);
65
64
  });
66
65
  });
66
+ },
67
+ connection: function () {
68
+ return new Promise(function (resolve, reject) {
69
+ pool.getConnection(function (err, connection) {
70
+ if (err)
71
+ return reject(err);
72
+ var query = function (sql) {
73
+ return new Promise(function (resolve, reject) {
74
+ connection.query(sql, function (err, result) {
75
+ if (err)
76
+ return reject(err);
77
+ return resolve(result);
78
+ });
79
+ });
80
+ };
81
+ var startTransaction = function () { return query('START TRANSACTION'); };
82
+ var commit = function () { return query('COMMIT'); };
83
+ var rollback = function () { return query('ROLLBACK'); };
84
+ return resolve({
85
+ query: query,
86
+ startTransaction: startTransaction,
87
+ commit: commit,
88
+ rollback: rollback
89
+ });
90
+ });
91
+ });
67
92
  }
68
93
  };
69
94
  };
70
- PoolConnection.prototype.options = function (options) {
71
- this.OPTIONS = new Map(Object.entries(options));
72
- return this;
95
+ PoolConnection.prototype._defaultOptions = function () {
96
+ var _a, _b, _c, _d, _e, _f;
97
+ return new Map(Object.entries({
98
+ connectionLimit: 10,
99
+ dateStrings: true,
100
+ connectTimeout: 1000 * 30,
101
+ acquireTimeout: 1000 * 30,
102
+ waitForConnections: false,
103
+ charset: 'utf8mb4',
104
+ host: String((_a = env_1.env.DB_HOST) !== null && _a !== void 0 ? _a : env_1.env.TSPACE_MYSQL_HOST),
105
+ port: Number.isNaN(Number((_b = env_1.env.DB_PORT) !== null && _b !== void 0 ? _b : env_1.env.TSPACE_MYSQL_PORT))
106
+ ? 3306
107
+ : Number((_c = env_1.env.DB_PORT) !== null && _c !== void 0 ? _c : env_1.env.TSPACE_MYSQL_PORT),
108
+ database: String((_d = env_1.env.DB_DATABASE) !== null && _d !== void 0 ? _d : env_1.env.TSPACE_MYSQL_DATABASE),
109
+ user: String((_e = env_1.env.DB_USERNAME) !== null && _e !== void 0 ? _e : env_1.env.TSPACE_MYSQL_USERNAME),
110
+ password: String((_f = env_1.env.DB_PASSWORD) !== null && _f !== void 0 ? _f : env_1.env.TSPACE_MYSQL_PASSWORD)
111
+ }));
112
+ };
113
+ PoolConnection.prototype._getJsonOptions = function () {
114
+ try {
115
+ var jsonPath = path_1.default.join(path_1.default.resolve(), 'tspace-mysql.json');
116
+ var jsonOptionsExists = fs_1.default.existsSync(jsonPath);
117
+ if (jsonOptionsExists) {
118
+ var jsonOptions = fs_1.default.readFileSync(jsonPath, 'utf8');
119
+ var options = JSON.parse(jsonOptions);
120
+ return new Map(Object.entries(options));
121
+ }
122
+ return this._defaultOptions();
123
+ }
124
+ catch (e) {
125
+ return this._defaultOptions();
126
+ }
127
+ };
128
+ PoolConnection.prototype._messageError = function () {
129
+ return "\n \u001B[1m\u001B[31m\n Connection lost to database ! \u001B[0m\n --------------------------------- \u001B[33m\n DB_HOST : ".concat(this.OPTIONS.get('host'), " \n DB_PORT : ").concat(this.OPTIONS.get('port'), " \n DB_DATABASE : ").concat(this.OPTIONS.get('database'), " \n DB_USERNAME : ").concat(this.OPTIONS.get('user'), " \n DB_PASSWORD : ").concat(this.OPTIONS.get('password'), " \u001B[0m \n ---------------------------------\n ");
73
130
  };
74
131
  return PoolConnection;
75
132
  }());
@@ -43,6 +43,12 @@ var constant = {
43
43
  NOT: 'NOT',
44
44
  DUPLICATE: 'DUPLICATE',
45
45
  KEY: 'KEY',
46
+ RAW: 'RAW',
47
+ WHEN: 'WHEN',
48
+ THEN: 'THEN',
49
+ ELSE: 'ELSE',
50
+ CASE: 'CASE',
51
+ END: 'END',
46
52
  WHERE_NOT_EXISTS: 'WHERE NOT EXISTS',
47
53
  EXISTS: 'EXISTS',
48
54
  VALUES: 'VALUES',
@@ -67,10 +73,7 @@ var constant = {
67
73
  camelCase: 'camelCase'
68
74
  },
69
75
  DB: {
70
- TRANSACTION: { query: [{
71
- table: '',
72
- id: ''
73
- }] },
76
+ PRIMARY_KEY: 'id',
74
77
  RESULT: null,
75
78
  DISTINCT: '',
76
79
  PLUCK: '',
@@ -100,10 +103,6 @@ var constant = {
100
103
  PER_PAGE: 1
101
104
  },
102
105
  MODEL: {
103
- TRANSACTION: { query: [{
104
- table: '',
105
- id: ''
106
- }] },
107
106
  PRIMARY_KEY: 'id',
108
107
  SELECT: '',
109
108
  DELETE: '',
@@ -132,6 +131,7 @@ var constant = {
132
131
  DEBUG: false,
133
132
  UUID: false,
134
133
  SOFT_DELETE: false,
134
+ SOFT_DELETE_FORMAT: 'deleted_at',
135
135
  SOFT_DELETE_RELATIONS: false,
136
136
  RELATION: [],
137
137
  WITH: [],
@@ -148,3 +148,4 @@ var constant = {
148
148
  }
149
149
  };
150
150
  exports.default = Object.freeze(constant);
151
+ // export default constant
@@ -2,7 +2,7 @@
2
2
  * The entry point.
3
3
  *
4
4
  * @module tspace-mysql
5
- */
5
+ */
6
6
  import * as tspace from './tspace';
7
7
  export * from './tspace';
8
8
  export default tspace;
package/dist/lib/index.js CHANGED
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
30
30
  * The entry point.
31
31
  *
32
32
  * @module tspace-mysql
33
- */
33
+ */
34
34
  var tspace = __importStar(require("./tspace"));
35
35
  __exportStar(require("./tspace"), exports);
36
36
  exports.default = tspace;
@@ -8,10 +8,12 @@ declare abstract class AbstractDatabase {
8
8
  protected $db: {
9
9
  get: Function;
10
10
  set: Function;
11
+ clone: Function;
11
12
  };
12
13
  protected $pool: {
13
14
  get: Function;
14
15
  set: Function;
16
+ load: Function;
15
17
  };
16
18
  protected $logger: {
17
19
  get: Function;
@@ -33,10 +35,7 @@ declare abstract class AbstractDatabase {
33
35
  abstract whereId(id: number): void;
34
36
  abstract whereUser(id: number): void;
35
37
  abstract whereEmail(value: string): void;
36
- abstract whereGroupStart(column: string, operator: string, value: string): void;
37
- abstract whereGroupEnd(column: string, operator: string, value: string): void;
38
- abstract orWhereGroupStart(column: string, operator: string, value: string): void;
39
- abstract orWhereGroupEnd(column: string, operator: string, value: string): void;
38
+ abstract whereQuery(callback: Function): void;
40
39
  abstract orWhere(column: string, operator: string, value: string): void;
41
40
  abstract whereIn(column: string, arrayValues: Array<any>): void;
42
41
  abstract orWhereIn(column: string, arrayValues: Array<any>): void;
@@ -82,6 +81,12 @@ declare abstract class AbstractDatabase {
82
81
  page: number;
83
82
  }): Promise<Pagination>;
84
83
  abstract first(): Promise<any>;
84
+ abstract firstOrError(message: string, options?: {
85
+ [key: string]: any;
86
+ }): Promise<any>;
87
+ abstract findOneOrError(message: string, options?: {
88
+ [key: string]: any;
89
+ }): Promise<any>;
85
90
  abstract get(): Promise<any>;
86
91
  abstract findOne(): Promise<any>;
87
92
  abstract findMany(): Promise<any>;
@@ -14,18 +14,18 @@ var AbstractDatabase = /** @class */ (function () {
14
14
  this.$constants = function (name) { };
15
15
  this.$db = {
16
16
  get: function (key) { },
17
- set: function (key, value) { }
17
+ set: function (key, value) { },
18
+ clone: function (data) { }
18
19
  };
19
20
  this.$pool = {
20
21
  get: function (sql) { },
21
- set: function (pool) { }
22
+ set: function (pool) { },
23
+ load: function () { }
22
24
  };
23
25
  this.$logger = {
24
26
  get: function () { },
25
27
  set: function (value) { },
26
- check: function (value) {
27
- return true || false;
28
- }
28
+ check: function (value) { return true || false; }
29
29
  };
30
30
  this.$attributes = {};
31
31
  }
@@ -1,21 +1,35 @@
1
- import { Relation } from './Interface';
1
+ import { Relation, RelationQuery } from './Interface';
2
2
  import Database from './Database';
3
3
  declare abstract class AbstractModel extends Database {
4
- abstract useDebug(): void;
5
- abstract useTable(table: string): void;
6
- abstract useTimestamp(): void;
7
- abstract useSoftDelete(): void;
8
- abstract usePattern(pattern: string): void;
9
- abstract onlyTrashed(): void;
10
- abstract trashed(): void;
11
- abstract restore(): void;
12
- abstract with(...nameRelations: string[]): void;
13
- abstract withQuery(nameRelations: string, callback: Function): void;
14
- abstract withExists(...nameRelations: string[]): void;
15
- abstract hasOne({ name, model, localKey, foreignKey, freezeTable, as }: Relation): void;
16
- abstract hasMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): void;
17
- abstract belongsTo({ name, model, localKey, foreignKey, freezeTable, as }: Relation): void;
18
- abstract belongsToMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): void;
4
+ abstract useUUID(): this;
5
+ abstract usePrimaryKey(primaryKey: string): this;
6
+ abstract useRegistry(): this;
7
+ abstract useDebug(): this;
8
+ abstract useTable(table: string): this;
9
+ abstract useTablePlural(): this;
10
+ abstract useTableSingular(): this;
11
+ abstract useTimestamp(): this;
12
+ abstract useSoftDelete(): this;
13
+ abstract usePattern(pattern: string): this;
14
+ abstract onlyTrashed(): Promise<any>;
15
+ abstract trashed(): Promise<any>;
16
+ abstract restore(): Promise<any>;
17
+ abstract ignoreSoftDelete(): this;
18
+ abstract disableSoftDelete(): this;
19
+ abstract registry(func: {
20
+ [key: string]: Function;
21
+ }): this;
22
+ abstract with(...nameRelations: string[]): this;
23
+ abstract withQuery(nameRelations: string, callback: Function): this;
24
+ abstract withExists(...nameRelations: string[]): this;
25
+ abstract hasOne({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
26
+ abstract hasMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
27
+ abstract belongsTo({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
28
+ abstract belongsToMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
29
+ abstract hasOneQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
30
+ abstract hasManyQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
31
+ abstract belongsToQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
32
+ abstract belongsToManyQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
19
33
  }
20
34
  export { AbstractModel };
21
35
  export default AbstractModel;
@@ -1,65 +1,136 @@
1
1
  declare class Blueprint {
2
2
  protected type: string;
3
3
  protected attrbuites: Array<string>;
4
- private _addAssignType;
5
- private _addAssignAttrbuite;
4
+ /**
5
+ * Assign type 'int' in table
6
+ * @return {this} this
7
+ */
6
8
  int(): this;
7
9
  /**
8
- * Assign type
9
- * @param {number}
10
+ * Assign type 'TINYINT' in table
11
+ * @param {number} number
12
+ * @return {this} this
10
13
  */
11
- tinyInt(n?: number): this;
14
+ tinyInt(number?: number): this;
12
15
  /**
13
- * Assign type
14
- * @param {number}
16
+ * Assign type 'BIGINT' in table
17
+ * @param {number} number [number = 10]
18
+ * @return {this} this
15
19
  */
16
- bigInt(n?: number): this;
20
+ bigInt(number?: number): this;
17
21
  /**
18
- * Assign type
22
+ * Assign type 'DOUBLE' in table
19
23
  * @param {number} length between 1-255
20
24
  * @param {number} decimal 0.000...n
25
+ * @return {this} this
21
26
  */
22
27
  double(length?: number, decimal?: number): this;
23
28
  /**
24
- * Assign type
29
+ * Assign type 'FLOAT' in table
25
30
  * @param {number} length between 1-255
26
31
  * @param {number} decimal 0.000...n
32
+ * @return {this} this
27
33
  */
28
34
  float(length?: number, decimal?: number): this;
29
35
  /**
30
- * Assign type
31
- * @param {number} length string between 1-255
36
+ * Assign type 'VARCHAR' in table
37
+ * @param {number} length [length = 100] length of string
38
+ * @return {this} this
32
39
  */
33
- varchar(n?: number): this;
40
+ varchar(length?: number): this;
34
41
  /**
35
- * Assign type
36
- * @param {number} length string between 1-255
42
+ * Assign type 'CHAR' in table
43
+ * @param {number} length [length = 1] length of string
44
+ * @return {this} this
45
+ */
46
+ char(length?: number): this;
47
+ /**
48
+ * Assign type 'LONGTEXT' in table
49
+ * @return {this} this
37
50
  */
38
- char(n?: number): this;
39
51
  longText(): this;
52
+ /**
53
+ * Assign type 'MEDIUMTEXT' in table
54
+ * @param {number} length [length = 1] length of string
55
+ * @return {this} this
56
+ */
40
57
  mediumText(): this;
58
+ /**
59
+ * Assign type 'TINYTEXT' in table
60
+ * @param {number} length [length = 1] length of string
61
+ * @return {this} this
62
+ */
41
63
  tinyText(): this;
64
+ /**
65
+ * Assign type 'TEXT' in table
66
+ * @param {number} length [length = 1] length of string
67
+ * @return {this} this
68
+ */
42
69
  text(): this;
43
70
  /**
44
- * Assign type
45
- * @param {...string} enum n1, n2, n3, ...n
71
+ * Assign type 'ENUM'
72
+ * @param {...string} enums n1, n2, n3, ...n
73
+ * @return {this} this
46
74
  */
47
75
  enum(...enums: Array<string>): this;
76
+ /**
77
+ * Assign type 'DATE' in table
78
+ * @return {this} this
79
+ */
48
80
  date(): this;
81
+ /**
82
+ * Assign type 'DATETIME' in table
83
+ * @return {this} this
84
+ */
49
85
  dateTime(): this;
86
+ /**
87
+ * Assign type 'TIMESTAMP' in table
88
+ * @return {this} this
89
+ */
50
90
  timestamp(): this;
91
+ /**
92
+ * Assign type 'UNSIGNED' in table
93
+ * @return {this} this
94
+ */
51
95
  unsigned(): this;
96
+ /**
97
+ * Assign type 'UNIQUE' in table
98
+ * @return {this} this
99
+ */
52
100
  unique(): this;
101
+ /**
102
+ * Assign type 'NULL' in table
103
+ * @return {this} this
104
+ */
53
105
  null(): this;
106
+ /**
107
+ * Assign type 'NOT NULL' in table
108
+ * @return {this} this
109
+ */
54
110
  notNull(): this;
111
+ /**
112
+ * Assign type 'PRIMARY KEY' in table
113
+ * @return {this} this
114
+ */
55
115
  primary(): this;
56
116
  /**
57
- * Assign attrbuites
58
- * @param {string | number} default value
117
+ * Assign attrbuites 'default' in table
118
+ * @param {string | number} n default value
119
+ * @return {this} this
59
120
  */
60
121
  default(n: string | number): this;
61
- defaultTimestamp(): this;
122
+ /**
123
+ * Assign attrbuites 'default currentTimestamp' in table
124
+ * @return {this} this
125
+ */
126
+ currentTimestamp(): this;
127
+ /**
128
+ * Assign attrbuites 'autoIncrement' in table
129
+ * @return {this} this
130
+ */
62
131
  autoIncrement(): this;
132
+ private _addAssignType;
133
+ private _addAssignAttrbuite;
63
134
  }
64
135
  export { Blueprint };
65
136
  export default Blueprint;