From 56e49d46a1a99e7ed46abe0ae8e9eea8e1180969 Mon Sep 17 00:00:00 2001 From: nabeelkausari Date: Sat, 3 Mar 2018 17:54:54 +0530 Subject: [PATCH] add sport name to image doc --- models/Image.js | 3 ++- server.js | 3 ++- src/App.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/models/Image.js b/models/Image.js index b5dd649..cb483b8 100644 --- a/models/Image.js +++ b/models/Image.js @@ -2,7 +2,8 @@ const mongoose = require('mongoose'); const ImageSchema = new mongoose.Schema({ fileName: String, - playerName: String + playerName: String, + sport: String },{ timestamps: { createdAt: '_created', updatedAt: '_updated' }, versionKey: false diff --git a/server.js b/server.js index ad53614..25d36f4 100644 --- a/server.js +++ b/server.js @@ -29,7 +29,8 @@ app.get('/file', (req, res) => { app.get('/saveImage', (req, res) => { let image = new Image ({ fileName: req.query.fileName, - playerName: req.query.playerName + playerName: req.query.playerName, + sport: req.query.sport }) image.save(err => { if (err) { diff --git a/src/App.js b/src/App.js index 445a3ae..7048310 100644 --- a/src/App.js +++ b/src/App.js @@ -56,7 +56,7 @@ class App extends Component { let fileName = file[file.length - 1]; let playerName = this.state.term; - fetch(`${apiUrl}saveImage?fileName=${fileName}&playerName=${playerName}`) + fetch(`${apiUrl}saveImage?fileName=${fileName}&playerName=${playerName}&sport=${this.props.sport.toLowerCase()}`) .then(res => res.json()); }