Skip to content

Commit

Permalink
last change on model, removed picture prop
Browse files Browse the repository at this point in the history
  • Loading branch information
brielsilva committed Feb 24, 2022
1 parent 084dafb commit bcbff0b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ DESAFIO:
● Telefone - phone

● Data de nascimento - birthday

● Foto - picture

● Foto caminho - picturePath (adicionado por mim)

● Foto - picturePath

● Data de criação do registro - createdAt

Expand Down
1 change: 0 additions & 1 deletion db/migrate/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = function createTable() {
phone VARCHAR NOT NULL,
gender CHAR(1) NOT NULL,
birthday DATE NOT NULL,
picture VARCHAR NOT NULL,
picturePath VARCHAR NOT NULL,
createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ services:
POSTGRES_DB: contacts_app
PG_DATA: /var/lib/postgresql/data/db-data/
PORT: 3000
AWS_ACCESS_KEY_ID:
AWS_SECRET_ACCESS_KEY:
AWS_ACCESS_KEY_ID: AKIATD2VUQXJZMQUXCP2
AWS_SECRET_ACCESS_KEY: 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
AWS_DEFAULT_REGION: sa-east-1
command: yarn start
ports:
Expand Down
4 changes: 1 addition & 3 deletions src/app/controllers/ContactController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class ContactsController {
}
async store(req,res) {
const {name, email, gender, birthday, phone} = req.body;
const picture = req.file.originalname;
const picturePath = req.file.location;
console.log(req.file);

if(!name && !email && !gender && !birthday && !phone && !picture) {
return res.status(400).json({ error: 'All fields are required'});
Expand All @@ -49,7 +47,7 @@ class ContactsController {
if(contactExists) {
return res.status(400).json({ error: 'This e-mail is already in use'});
}
const contact = await ContactsRepository.create({name,email,gender,birthday,phone,picture,picturePath});;
const contact = await ContactsRepository.create({name,email,gender,birthday,phone,picturePath});;

res.json(contact);
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/repositories/ContactsRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const db = require('../../../db/db');

class ContactsRepository {

async create({name, email, phone, gender, picture, picturePath,birthday,}) {
const row = await db.query('INSERT INTO contacts(name,email,phone,gender,picture,birthday,picturePath) VALUES($1,$2,$3,$4,$5,$6,$7) RETURNING *',[name,email,phone,gender,picturePath,birthday,picturePath]);
async create({name, email, phone, gender, picturePath,birthday,}) {
const row = await db.query('INSERT INTO contacts(name,email,phone,gender,birthday,picturePath) VALUES($1,$2,$3,$4,$5,$6) RETURNING *',[name,email,phone,gender,birthday,picturePath]);

return row[0];
}
Expand Down

0 comments on commit bcbff0b

Please sign in to comment.