Created
July 3, 2017 16:23
-
-
Save fetttobse/56fbd0e74670aa56f8debdd7077637c1 to your computer and use it in GitHub Desktop.
JavaScript die Hurensohn
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
import Connection from './db.js'; | |
let lsz = 250; | |
let name = Array([lsz]); | |
let alpha2 = Array([lsz]); | |
//Arrayfelder befüllen | |
export const addCountries = function () { | |
for (let i = 0; i < 249; i++) { | |
Connection.models.country.create({ | |
short: alpha2[i], | |
name: name[i] | |
}); | |
} | |
} |
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
import Sequelize from 'sequelize'; | |
import { addCountries } from './addCountries'; | |
const Connection = new Sequelize(); | |
//Model Definitions mit Sequelize | |
//Relation Definitions mit Sequelize | |
//ON FIRST RUN: | |
let firstRun = true; | |
if (firstRun) { | |
//Sync with Database | |
//Force will delete all existing data and overwrite table definitions! | |
Connection.sync({ force: true }); | |
addCountries(); | |
} | |
export default Connection; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment