How to use the STRING function from sequelize
Find comprehensive JavaScript sequelize.STRING code examples handpicked from public code repositorys.
GitHub: ZeroCho/nodejs-book
![ZeroCho profile picture](/ZeroCho.png?size=40)
5 6 7 8 9 10 11 12 13 14
name: { type: Sequelize.STRING(40), allowNull: false, }, img: { type: Sequelize.STRING(200), allowNull: true, }, price: { type: Sequelize.INTEGER,
+ 3 other calls in file
21 22 23 24 25 26 27 28 29 30
min: 0, idle: 10000 } }); const ID_TYPE = Sequelize.STRING(50); function defineModel(name, attributes) { var attrs = {}; for (let key in attributes) {
+ 3 other calls in file
GitHub: jsha/blocktogether
![jsha profile picture](/jsha.png?size=40)
182 183 184 185 186 187 188 189 190
* are a simple representation of the current state of a user's blocks based on * what the Twitter API returns. */ var SharedBlock = sequelize.define('SharedBlock', { author_uid: Sequelize.STRING, sink_uid: Sequelize.STRING }); SharedBlock.belongsTo(BtUser, {foreignKey: 'author_uid'}); SharedBlock.belongsTo(TwitterUser, {foreignKey: 'sink_uid'});
76 77 78 79 80 81 82 83 84 85
} } if (attributeName === 'id') { delete this[attributeName].allowNull Object.assign(this[attributeName], { type: DataTypes.STRING(128), primaryKey: true }) } }
+ 3 other calls in file
GitHub: osmlab/to-fix-backend
![osmlab profile picture](/osmlab.png?size=40)
48 49 50 51 52 53 54 55 56 57
type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.NOW }, lockedBy: { type: Sequelize.STRING }, metadata: { type: Sequelize.JSONB, allowNull: false,
22 23 24 25 26 27 28 29 30 31
* along with this program. If not, see <https://www.gnu.org/licenses/agpl.html>. */ var Sequelize = require('sequelize'); exports._STRING = Sequelize.STRING; exports._CHAR = Sequelize.CHAR; exports._TEXT = Sequelize.TEXT; exports._INTEGER = Sequelize.INTEGER; exports._BIGINT = Sequelize.BIGINT;
+ 9 other calls in file
94 95 96 97 98 99 100 101 102 103
allowNull: false, primaryKey: true, autoIncrement: true }, username: { type: DataTypes.STRING(20), allowNull: true }, aNumber: { type: DataTypes.SMALLINT,
+ 3 other calls in file
35 36 37 38 39 40 41 42 43 44
|| type instanceof Sequelize.UUIDV4) { return { type: addNull ? ['string', 'null'] : 'string', format: 'uuid' }; } if (type instanceof Sequelize.CHAR || type instanceof Sequelize.STRING || type instanceof Sequelize.TEXT || type instanceof Sequelize.UUID || type instanceof Sequelize.DATE || type instanceof Sequelize.DATEONLY
+ 2 other calls in file
43 44 45 46 47 48 49 50 51 52
comment: 'id', field: 'id' }, topic_id: { // 话题名字 type: Seq.STRING(100), defaultValue: () => { return uuid(24) }, comment: 'topic_id',
+ 9 other calls in file
19 20 21 22 23 24 25 26 27 28
password: { //管理员密码 type: Sequelize.STRING, allowNull: false, }, role: { //角色 1超级管理员、2普通管理员 type: Sequelize.STRING(2), defaultValue: "1", }, }, { freezeTableName: true, // 自定义表名
16 17 18 19 20 21 22 23 24 25
defaultValue: DataType.UUIDV1, primaryKey: true, }, email: { type: DataType.STRING(255), validate: { isEmail: true }, }, emailConfirmed: {
8 9 10 11 12 13 14 15 16 17
allowNull: false, type: Sequelize.UUID, defaultValue: Sequelize.UUIDV1, }, name: { type: Sequelize.STRING(1024), field: 'name', }, amount: { type: Sequelize.DECIMAL(19, 4),
GitHub: adonespitogo/AdoBot-IO
![adonespitogo profile picture](/adonespitogo.png?size=40)
36 37 38 39 40 41 42 43 44 45
}, socket_id: { type: Sequelize.STRING, length: 100 }, sms_forwarder_number: Sequelize.STRING(50), sms_forwarder_status: { type: Sequelize.BOOLEAN, defaultValue: false }
GitHub: apachecn/zetcode-zh
![apachecn profile picture](/apachecn.png?size=40)
132 133 134 135 136 137 138 139 140 141
const sequelize = new Sequelize(path, { operatorsAliases: false }); let Dummy = sequelize.define('dummy', { description: Sequelize.STRING }); Dummy.sync().then(() => { console.log('New table created');
+ 7 other calls in file
GitHub: fairlayer/fair
![fairlayer profile picture](/fairlayer.png?size=40)
84 85 86 87 88 89 90 91 92 93
code: Sequelize.TEXT, patch: Sequelize.TEXT, delayed: Sequelize.INTEGER, //cron kindof: Sequelize.STRING }) const Vote = sequelize.define('vote', { rationale: Sequelize.TEXT,
+ 3 other calls in file
67 68 69 70 71 72 73 74 75 76
type: STRING(2), allowNull: true }, [`v${col}`]: { comment: `Value for ${col}`, type: STRING(valueBaseLength), allowNull: true } })) ), {
+ 3 other calls in file
GitHub: maoxiaoquan/kite
![maoxiaoquan profile picture](/maoxiaoquan.png?size=40)
66 67 68 69 70 71 72 73 74 75
field: 'comment_count', defaultValue: 0 }, tag_ids: { /* 小书所属的标签名字 可多个 */ type: Seq.STRING(180), comment: '书所属的标签id', field: 'tag_ids' }, status: {
+ 5 other calls in file
GitHub: qtumproject/qtuminfo
![qtumproject profile picture](/qtumproject.png?size=40)
39 40 41 42 43 44 45 46 47 48
type: Sequelize.BIGINT.UNSIGNED, field: '_id', primaryKey: true }, contractAddress: Sequelize.CHAR(20).BINARY, tag: Sequelize.STRING(32) }, {freezeTableName: true, underscored: true, timestamps: false}) Contract.hasOne(ContractCode, {as: 'code', foreignKey: 'contractAddress'}) ContractCode.belongsTo(Contract, {as: 'contract', foreignKey: 'contractAddress'})
GitHub: ruojs/ruo
![ruojs profile picture](/ruojs.png?size=40)
47 48 49 50 51 52 53 54 55 56
primaryKey: true, autoIncrement: true, allowNull: false, }, name: { type: Sequelize.STRING(20), allowNull: false, }, }, { tableName: 'user',
99 100 101 102 103 104 105 106 107 108
const length = rules.filter(o => o.name === 'length' || o.name === 'max').map(o => o.arg)[0]; switch (type) { case 'string': if (length) { return Sequelize.STRING(length); } return Sequelize.TEXT; case 'array':
sequelize.col is the most popular function in sequelize (1002 examples)