本文整理汇总了TypeScript中Sequelize.STRING函数的典型用法代码示例。如果您正苦于以下问题:TypeScript STRING函数的具体用法?TypeScript STRING怎么用?TypeScript STRING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STRING函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: up
async function up (utils: {
transaction: Sequelize.Transaction,
queryInterface: Sequelize.QueryInterface,
sequelize: Sequelize.Sequelize
}): Promise<void> {
{
const data = {
type: Sequelize.STRING(500),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.changeColumn('video', 'support', data)
}
{
const data = {
type: Sequelize.STRING(500),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.changeColumn('videoChannel', 'support', data)
}
{
const data = {
type: Sequelize.STRING(500),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.changeColumn('videoChannel', 'description', data)
}
}
示例2: up
async function up (utils: {
transaction: Sequelize.Transaction,
queryInterface: Sequelize.QueryInterface,
sequelize: Sequelize.Sequelize,
db: any
}): Promise<void> {
{
const data = {
type: Sequelize.INTEGER,
allowNull: true,
defaultValue: null
}
await utils.queryInterface.changeColumn('Videos', 'licence', data)
}
{
const data = {
type: Sequelize.INTEGER,
allowNull: true,
defaultValue: null
}
await utils.queryInterface.changeColumn('Videos', 'category', data)
}
{
const data = {
type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.changeColumn('Videos', 'description', data)
}
}
示例3: getSequelizeType
export function getSequelizeType(model: IModel): Sequelize.DataTypeAbstract {
const type = model.spec.type
const format = model.spec.format
// tslint:disable-next-line
switch (format) {
case 'uuid':
return Sequelize.UUID()
case 'integer':
return Sequelize.BIGINT()
}
switch (type) {
case ModelType.String:
const maxLength = model.spec.max
return maxLength ? Sequelize.STRING(maxLength) : Sequelize.TEXT()
case ModelType.Number:
return Sequelize.DOUBLE()
case ModelType.Boolean:
return Sequelize.BOOLEAN
case ModelType.DateTime:
return Sequelize.DATE(6)
default:
// record will be JSONified
return Sequelize.TEXT()
}
}
示例4: up
async function up (utils: {
transaction: Sequelize.Transaction,
queryInterface: Sequelize.QueryInterface,
sequelize: Sequelize.Sequelize
}): Promise<void> {
{
const data = {
type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.addColumn('video', 'support', data)
}
{
const data = {
type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.addColumn('videoChannel', 'support', data)
}
{
const data = {
type: Sequelize.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.addColumn('account', 'description', data)
}
{
const data = {
type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.changeColumn('video', 'description', data)
}
}
示例5: defineTask
export default function defineTask(sequelize: Sequelize.Sequelize, DataTypes) {
let Task = sequelize.define('Task', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
title: {
type: Sequelize.STRING(20)
},
description: {
type: Sequelize.STRING(50)
},
status: {
type: Sequelize.BOOLEAN,
defaultValue: false
}
});
Task.sync();
return Task;
}
示例6: up
async function up (utils: {
transaction: Sequelize.Transaction,
queryInterface: Sequelize.QueryInterface,
sequelize: Sequelize.Sequelize,
db: any
}): Promise<void> {
const q = utils.queryInterface
const data = {
type: Sequelize.STRING(3000),
allowNull: false
}
await q.changeColumn('Videos', 'description', data)
}
示例7: up
function up (utils: {
transaction: Sequelize.Transaction,
queryInterface: Sequelize.QueryInterface,
sequelize: Sequelize.Sequelize
}): Promise<void> {
const q = utils.queryInterface
const data = {
type: Sequelize.STRING(400),
allowNull: false,
defaultValue: ''
}
return q.addColumn('Users', 'email', data)
.then(() => {
const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')'
return utils.sequelize.query(query, { transaction: utils.transaction })
})
.then(() => {
data.defaultValue = null
return q.changeColumn('Users', 'email', data)
})
}
示例8:
// Possible values: 'json', 'sequelize', an object
storage: 'sequelize',
storageOptions: {
// The configured instance of Sequelize.
// Optional if `model` is passed.
sequelize: sequelize,
// The to be used Sequelize model.
// Must have column name matching `columnName` option
// Optional of `sequelize` is passed.
model: sequelize.define<any, any>('model', {}),
// The name of the to be used model.
// Defaults to 'SequelizeMeta'
modelName: 'Schema',
// The name of table to create if `model` option is not supplied
// Defaults to `modelName`
tableName: 'Schema',
// The name of table column holding migration name.
// Defaults to 'name'.
columnName: 'migration',
// The type of the column holding migration name.
// Defaults to `Sequelize.STRING`
columnType: Sequelize.STRING(100),
},
});
示例9: up
async function up (utils: {
transaction: Sequelize.Transaction,
queryInterface: Sequelize.QueryInterface,
sequelize: Sequelize.Sequelize
}): Promise<void> {
{
await utils.queryInterface.renameColumn('video', 'language', 'oldLanguage')
}
{
const data = {
type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.LANGUAGE.max),
allowNull: true,
defaultValue: null
}
await utils.queryInterface.addColumn('video', 'language', data)
}
{
const languages = [
{
oldLanguage: 1,
newLanguage: 'en'
},
{
oldLanguage: 2,
newLanguage: 'es'
},
{
oldLanguage: 3,
newLanguage: 'zh'
},
{
oldLanguage: 4,
newLanguage: 'hi'
},
{
oldLanguage: 5,
newLanguage: 'ar'
},
{
oldLanguage: 6,
newLanguage: 'pt'
},
{
oldLanguage: 7,
newLanguage: 'bn'
},
{
oldLanguage: 8,
newLanguage: 'ru'
},
{
oldLanguage: 9,
newLanguage: 'ja'
},
{
oldLanguage: 10,
newLanguage: 'pa'
},
{
oldLanguage: 11,
newLanguage: 'de'
},
{
oldLanguage: 12,
newLanguage: 'ko'
},
{
oldLanguage: 13,
newLanguage: 'fr'
},
{
oldLanguage: 14,
newLanguage: 'it'
},
{
oldLanguage: 1000,
newLanguage: 'sgn'
},
{
oldLanguage: 1001,
newLanguage: 'ase'
},
{
oldLanguage: 1002,
newLanguage: 'sdl'
},
{
oldLanguage: 1003,
newLanguage: 'bfi'
},
{
oldLanguage: 1004,
newLanguage: 'bzs'
},
{
oldLanguage: 1005,
newLanguage: 'csl'
//.........这里部分代码省略.........
示例10:
config.password, // 用户密码
{
'dialect': 'mysql', // 数据库使用mysql
'host': config.server, // 数据库服务器ip
'port': 3306, // 数据库服务器端口
'define': {
// 字段以下划线(_)来分割(默认是驼峰命名风格)
'underscored': true
},
logging:false//关闭输出sql日志
}
);
let ImgDb = sequelize.define('img', {
'url': {
'type': Sequelize.STRING(255),
'allowNull': true,
'unique': true // 字段是否UNIQUE
},
'time': {
'type': Sequelize.DATE(10),
'allowNull': true
},
'titleId': {
'type': Sequelize.STRING(100),
'allowNull': true
}
}, {
// 自定义表名
'freezeTableName': true,
'tableName': 'node_img',