Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sequelize/data/entity.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"name": "The Leftorium",
"type": "Test",
"address": {
"street": [
"123 Anyplace St."
Expand All @@ -17,6 +18,7 @@
},
{
"name": "Moes Tavern",
"type": "Test",
"address": {
"street": [
"123 Anyplace St."
Expand Down
5 changes: 4 additions & 1 deletion sequelize/migrations/04-create-demo-entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ module.exports = {
name : {
type: Sequelize.STRING,
required: true
},
},
type : {
type: Sequelize.STRING
},
address: {
type: Sequelize.JSON,
},
Expand Down
29 changes: 2 additions & 27 deletions sequelize/seeders/03-demo-entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ module.exports = {
element.phone = JSON.stringify(element.phone);
element.address = JSON.stringify(element.address);
}

let i = 0;

const entityNames = [
"Springfield Bowlorama",
"Springfield Nuclear Power Plant",
Expand All @@ -34,6 +33,7 @@ module.exports = {
createdAt: new Date(),
updatedAt: new Date(),
name: name,
type: "Test",
address: JSON.stringify({
street: [
`123 ${randomWords()} St.`
Expand All @@ -50,31 +50,6 @@ module.exports = {
});
}

// do {
// let name = randomWords();
// entities.push({
// id: uuid(),
// createdAt: new Date(),
// updatedAt: new Date(),
// name: name.charAt(0).toUpperCase() + name.slice(1),
// address: JSON.stringify({
// street: [
// "123 Anyplace St."
// ],
// city: "Baltimore",
// state: "MD",
// zip: "12345",
// latlng: [
// 39.296399,
// -76.607842
// ]
// }),
// description: randomWords(5)
// });
// i++;
// } while (i < 26);


return queryInterface.bulkInsert('Entities', entities);
},
down: queryInterface => {
Expand Down
3 changes: 3 additions & 0 deletions src/models/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const entity = (sequelize, DataTypes) => {
type: DataTypes.STRING,
required: true
},
type : {
type: DataTypes.STRING
},
address: {
type: DataTypes.JSON,
},
Expand Down
10 changes: 9 additions & 1 deletion src/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ import path from 'path';
import fs from 'fs';
import _ from 'lodash';

let dbUrl;

if (process.env.DATABASE_URL) {
dbUrl = process.env.DATABASE_URL;
} else {
dbUrl = `postgres://${process.env.DATABASE_USERNAME}:${process.env.DATABASE_PASSWORD}@${process.env.DATABASE_HOST}:${process.env.DATABASE_PORT}/${process.env.DATABASE_NAME}`;
}

// Initializes the database.
const sequelize = new Sequelize(
process.env.DATABASE_URL,
dbUrl,
{
dialect: 'postgres'
}
Expand Down