Skip to content

Instantly share code, notes, and snippets.

@fetttobse
Created July 3, 2017 16:23
Show Gist options
  • Save fetttobse/56fbd0e74670aa56f8debdd7077637c1 to your computer and use it in GitHub Desktop.
Save fetttobse/56fbd0e74670aa56f8debdd7077637c1 to your computer and use it in GitHub Desktop.
JavaScript die Hurensohn
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]
});
}
}
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