
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@icreate/ics-db-migrate
Advanced tools
npm i @icreate/ics-db-migrate
import { createDBMigrate, DataType as type, DBType } from @icreate/ics-db-migrate
var sqlBuilder = createDBMigrate(DBType.mssql)
{
name: string // 中文名
primaryKey: boolean // 主键
notNull: boolean // 不可为空
autoIncrement: boolean // 自增
type: string // 数据类型
length: number // 长度
precision: number // 精度
comment: string // 说明
defaultValue: string | number // 默认值
foreignKey: { // 外键
name: string // 外键名
table: string // 关联表
mapping: string // 关联列
}
}
// 创建列定义
var colOptions = {
ID: {
name: '主键ID',
primaryKey: true,
notNull: true,
type: type.VarChar,
length: 50
},
NAME: {
name: '名称',
notNull: true,
type: type.VarChar,
length: 200
},
SEX: {
name: '性别',
notNull: true,
type: type.VarChar,
length: 20
},
AGE: {
name: '年龄',
notNull: true,
type: type.Int
}
}
sqlBuilder.createTable('TEST', colOptions, '测试表')
sqlBuilder.truncate('TEST')
sqlBuilder.createView('VIEW_TEST', `SELECT ID, NAME, AGE FROM TEST`)
// 函数SQL
const SQL =
`
create function FUNC_TEST
([p1,p2...pn])
return datatype
is|as
--声明部分
begin
--PL/SQL程序块
end
`
sqlBuilder.createFunction('FUNC_TEST', SQL)
// 存储过程SQL
const SQL =
`
create procedure 存储过程名(param1 in type,param2 out type)
as
变量1 类型(值范围);
变量2 类型(值范围);
begin
select count(*) into 变量1 from 表A where列名=param1;
if (判断条件) then
select 列名 into 变量2 from 表A where列名=param1;
dbms_output.Put_line('打印信息');
elsif (判断条件) then
dbms_output.Put_line('打印信息');
else
raise 异常名(NO_DATA_FOUND);
end if;
exception
when others then
rollback;
end;
`
sqlBuilder.createProcedure('PROC_TEST', SQL)
sqlBuilder.dropTable('TEST')
sqlBuilder.dropView('VIEW_TEST')
sqlBuilder.dropFunction('FUNC_TEST')
sqlBuilder.dropProcedure('PROC_TEST')
// 列定义
const option = {
name: '备注',
type: type.VarChar,
length: 1000
}
sqlBuilder.addColumn('TEST', 'REMARK', option)
sqlBuilder.removeColumn('TEST', 'REMARK')
option.length = 2000
sqlBuilder.changeColumn('TEST', 'REMARK', option)
sqlBuilder.addIndex('TEST', 'IX_TEST_NAME', ['NAME'], false)
sqlBuilder.removeIndex('TEST', 'IX_TEST_NAME')
var data = {
ID: '123456789',
NAME: '666666',
SEX: '男',
AGE: 19
}
sqlBuilder.insert('TEST', data)
var data = {
SEX: '男',
AGE: 19
}
var where = {
ID: '123456789'
}
sqlBuilder.update('TEST', data, where)
var where = {
ID: '123456789'
}
sqlBuilder.remove('TEST', where)
sqlBuilder.addForeignKey('fk_test','TEST','NAME','TEST2','NAME')
sqlBuilder.removeForeignKey('TEST','fk_test')
var sqlText = sqlBuilder.text()
FAQs
``` npm i @icreate/ics-db-migrate ```
We found that @icreate/ics-db-migrate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.