forked from CodeForPoznan/alinka-electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
123 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const SchoolType = require("./school_type"); | ||
const School = require("./school"); | ||
|
||
module.exports = { | ||
SchoolType, | ||
School | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const Sequelize = require("sequelize"); | ||
const { DataTypes } = require("sequelize"); | ||
|
||
const sequelize = require("../db_config").sequelize; | ||
|
||
const School = sequelize.define( | ||
"School", | ||
{ | ||
id: { | ||
type: Sequelize.INTEGER, | ||
unique: true, | ||
autoIncrement: true, | ||
primaryKey: true | ||
}, | ||
name: { | ||
type: Sequelize.STRING(80), | ||
allowNull: false | ||
}, | ||
city: { | ||
type: Sequelize.STRING(80), | ||
allowNull: false | ||
}, | ||
postCode: { | ||
type: Sequelize.STRING(6), | ||
allowNull: false | ||
}, | ||
postOffice: { | ||
type: Sequelize.STRING(80), | ||
allowNull: false | ||
}, | ||
street: { | ||
type: Sequelize.STRING(80), | ||
allowNull: false | ||
}, | ||
address: { | ||
type: Sequelize.VIRTUAL(DataTypes.STRING, ["city", "street"]), | ||
get() { | ||
return `${this.getDataValue("city")}, ${this.getDataValue("street")}`; | ||
} | ||
}, | ||
post: { | ||
type: Sequelize.VIRTUAL(DataTypes.STRING, ["postCode", "postOffice"]), | ||
get() { | ||
const { postOffice, city, postCode } = this; | ||
const postLocation = postOffice === city ? city : postOffice; | ||
return `${postCode} ${postLocation}`; | ||
} | ||
} | ||
}, | ||
{ | ||
// options | ||
} | ||
); | ||
|
||
module.exports = School; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const Sequelize = require("sequelize"); | ||
const sequelize = require("../db_config").sequelize; | ||
const School = require("./school"); | ||
|
||
const SchoolType = sequelize.define( | ||
"SchoolType", | ||
{ | ||
name: { | ||
type: Sequelize.STRING(80), | ||
allowNull: false, | ||
unique: true, | ||
primaryKey: true | ||
} | ||
}, | ||
{ | ||
// options | ||
} | ||
); | ||
|
||
SchoolType.hasMany(School, { foreignKey: { allowNull: false } }); | ||
|
||
module.exports = SchoolType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
const { SchoolType } = require("../../db/models"); | ||
const SchoolType = require("../../db/models/school_type"); | ||
const schoolTypeList = require("../../db/school_types"); | ||
const faker = require("faker/locale/pl"); | ||
|
||
const schoolTypeData = () => { | ||
return faker.random.arrayElement(schoolTypeList); | ||
}; | ||
|
||
const schoolTypeFixture = async name => | ||
await SchoolType.create({ name: name || schoolTypeData() }); | ||
const schoolTypeFixture = async name =>{ | ||
return await SchoolType.create({ name: name || schoolTypeData() }); | ||
} | ||
|
||
module.exports = schoolTypeFixture; | ||
module.exports.schoolTypeData = schoolTypeData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters