Skip to content

Commit

Permalink
Доработка модели User (#8)
Browse files Browse the repository at this point in the history
* add chat id property

* remove stat model

* change user properties

* add chat id
  • Loading branch information
extremecodetv authored Jun 25, 2018
1 parent 1ebdc59 commit 2d42a9c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/handlers/stats.handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ module.exports = async (msg) => {
});

if (!user) {
from.chat_id = msg.chat.id;
user = await createUser(from);
user.Counter = await user.getCounter();
} else {
Expand Down
22 changes: 0 additions & 22 deletions src/models/stat.model.js

This file was deleted.

8 changes: 4 additions & 4 deletions src/models/user.model.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define('User', {
chat_id: {
type: DataTypes.STRING, // not int, cuz out of range
allowNull: false
},
telegram_id: {
type: DataTypes.INTEGER,
allowNull: false,
Expand All @@ -25,10 +29,6 @@ module.exports = (sequelize, DataTypes) => {
is_admin: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
is_bot: {
type: DataTypes.BOOLEAN,
allowNull: false
}
}, {
underscored: true,
Expand Down

0 comments on commit 2d42a9c

Please sign in to comment.