How to use the STRING function from sequelize
Find comprehensive JavaScript sequelize.STRING code examples handpicked from public code repositorys.
GitHub: ZeroCho/nodejs-book
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,
636
703
15
+ 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) {
195
641
36
+ 3 other calls in file
GitHub: jsha/blocktogether
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'});
74
332
25
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 }) } }
31
33
60
+ 3 other calls in file
GitHub: osmlab/to-fix-backend
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,
13
15
24
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;
10
15
25
+ 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,
497
0
59
+ 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
22
0
15
+ 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',
115
517
11
+ 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, // 自定义表名
11
12
1
16 17 18 19 20 21 22 23 24 25
defaultValue: DataType.UUIDV1, primaryKey: true, }, email: { type: DataType.STRING(255), validate: { isEmail: true }, }, emailConfirmed: {
4
11
32
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),
1
6
2
GitHub: adonespitogo/AdoBot-IO
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 }
155
177
23
GitHub: apachecn/zetcode-zh
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');
35
139
0
+ 7 other calls in file
GitHub: fairlayer/fair
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,
16
80
23
+ 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 } })) ), {
1
1
15
+ 3 other calls in file
GitHub: maoxiaoquan/kite
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: {
115
516
11
+ 5 other calls in file
GitHub: qtumproject/qtuminfo
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'})
31
13
5
GitHub: ruojs/ruo
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',
10
15
6
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':
6
0
6
sequelize.col is the most popular function in sequelize (1002 examples)