How to use the STRING function from sequelize

Find comprehensive JavaScript sequelize.STRING code examples handpicked from public code repositorys.

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,
fork icon636
star icon703
watch icon15

+ 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) {
fork icon195
star icon641
watch icon36

+ 3 other calls in file

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'});
fork icon74
star icon332
watch icon25

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
    })
  }
}
fork icon31
star icon33
watch icon60

+ 3 other calls in file

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,
fork icon13
star icon15
watch icon24

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;
fork icon10
star icon15
watch icon25

+ 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,
fork icon497
star icon0
watch icon59

+ 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
fork icon22
star icon0
watch icon15

+ 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',
fork icon115
star icon517
watch icon11

+ 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, // 自定义表名
fork icon11
star icon12
watch icon1

16
17
18
19
20
21
22
23
24
25
  defaultValue: DataType.UUIDV1,
  primaryKey: true,
},

email: {
  type: DataType.STRING(255),
  validate: { isEmail: true },
},

emailConfirmed: {
fork icon4
star icon11
watch icon32

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),
fork icon1
star icon6
watch icon2

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
}
fork icon155
star icon177
watch icon23

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');
fork icon35
star icon139
watch icon0

+ 7 other calls in file

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,
fork icon16
star icon80
watch icon23

+ 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
      }
    }))
), {
fork icon1
star icon1
watch icon15

+ 3 other calls in file

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: {
fork icon115
star icon516
watch icon11

+ 5 other calls in file

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'})
fork icon31
star icon13
watch icon5

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',
fork icon10
star icon15
watch icon6

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':
fork icon6
star icon0
watch icon6