-
Notifications
You must be signed in to change notification settings - Fork 39
Смирнов Алексей #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Смирнов Алексей #14
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,23 @@ | |
|
|
||
| module.exports = (sequelize, DataTypes) => { | ||
| // Ваша модель страны | ||
| return sequelize.define('countries', { | ||
| id: { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тоже |
||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| primaryKey: true, | ||
| autoIncrement: true | ||
| }, | ||
| name: { | ||
| type: DataTypes.TEXT, | ||
| unique: true | ||
| } | ||
| }, { | ||
| indexes: [ | ||
| { | ||
| name: 'countries_name', | ||
| fields: ['name'] | ||
| } | ||
| ] | ||
| }); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,35 @@ | |
|
|
||
| module.exports = (sequelize, DataTypes) => { | ||
| // Ваша модель отзыва | ||
| return sequelize.define('reviews', { | ||
| id: { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тоже |
||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| primaryKey: true, | ||
| autoIncrement: true | ||
| }, | ||
| text: DataTypes.TEXT, | ||
| rating: { | ||
| type: DataTypes.INTEGER, | ||
| validate: { min: 0, max: 5 } | ||
| }, | ||
| isApproved: { | ||
| type: DataTypes.BOOLEAN, | ||
| defaultValue: false | ||
| }, | ||
| souvenirId: { | ||
| type: DataTypes.INTEGER, | ||
| reference: { | ||
| model: 'souvenirs', | ||
| key: 'id' | ||
| } | ||
| }, | ||
| userId: { | ||
| type: DataTypes.INTEGER, | ||
| reference: { | ||
| model: 'users', | ||
| key: 'id' | ||
| } | ||
| } | ||
| }); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,43 @@ | |
|
|
||
| module.exports = (sequelize, DataTypes) => { | ||
| // Ваша модель сувенира | ||
| return sequelize.define('souvenirs', { | ||
| id: { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тоже |
||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| primaryKey: true, | ||
| autoIncrement: true | ||
| }, | ||
| name: { | ||
| type: DataTypes.TEXT, | ||
| allowNull: false | ||
| }, | ||
| image: DataTypes.TEXT, | ||
| price: { | ||
| type: DataTypes.DOUBLE, | ||
| allowNull: false, | ||
| validate: { min: 0 } | ||
| }, | ||
| rating: { | ||
| type: DataTypes.DOUBLE, | ||
| validate: { min: 0, max: 5 } | ||
| }, | ||
| amount: { | ||
| type: DataTypes.INTEGER, | ||
| validate: { min: 0 }, | ||
| defaultValue: 0 | ||
| }, | ||
| isRecent: DataTypes.BOOLEAN, | ||
| countryId: { | ||
| type: DataTypes.INTEGER, | ||
| reference: { | ||
| model: 'countries', | ||
| key: 'id' | ||
| } | ||
| } | ||
| }, { | ||
| indexes: [{ | ||
| fields: ['rating', 'price'] | ||
| }] | ||
| }); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,13 @@ | |
|
|
||
| module.exports = (sequelize, DataTypes) => { | ||
| // Ваша модель тэга | ||
| return sequelize.define('tags', { | ||
| id: { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тоже |
||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| primaryKey: true, | ||
| autoIncrement: true | ||
| }, | ||
| name: DataTypes.TEXT | ||
| }); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если связи указаны правильно, id'шки сами подтянутся