diff --git a/lib/clientMethods.js b/lib/clientMethods.js index a7d1c47..ff45dbc 100644 --- a/lib/clientMethods.js +++ b/lib/clientMethods.js @@ -4,6 +4,7 @@ const config = require('config'); module.exports = (clientAddress) => { let thisClient = null; + console.log("config.clients: ", config.clients); Object.keys(config.clients).forEach((client) => { if (config.clients[client] === clientAddress || config.clients[client].indexOf(clientAddress) > -1) { thisClient = client; diff --git a/methods/report/put.js b/methods/report/put.js index 13d7ac3..d1839e6 100644 --- a/methods/report/put.js +++ b/methods/report/put.js @@ -3,7 +3,7 @@ const log = require('../../lib/logger'); const handleError = (req, res, err) => { - log.warn(`[${req.body.id}] method: ${req.body.method} error: ${err.message} ${err.stack}"`); + log.warn(`[${req.body.id}] method: ${req.body.method} error: ${err.message} ${err.stack}`); res.status(500).send({ id: req.body.id, error: 'Error saving report', diff --git a/schemas/report.js b/schemas/report.js index 1b9621f..b622749 100644 --- a/schemas/report.js +++ b/schemas/report.js @@ -50,11 +50,13 @@ Report.methods.getElasticSearchClient = function getElasticSearchClient() { Report.methods.createInElasticSearch = function createInElasticSearch(cb) { const client = this.getElasticSearchClient(); const body = this.toJSON(); - log.debug('Creating in ElasticSearch...', body._id); + const id = body._id.toString(); + delete body._id; + log.debug('Creating in ElasticSearch...', id); client.create({ index: 'data-api', type: 'report', - id: body._id.toString(), + id: id, body }, cb); }; @@ -62,11 +64,12 @@ Report.methods.createInElasticSearch = function createInElasticSearch(cb) { Report.methods.deleteInElasticSearch = function deleteInElasticSearch(cb) { const client = this.getElasticSearchClient(); const body = this.toJSON(); + const id = body._id.toString(); log.debug('Deleting from ElasticSearch...'); client.delete({ index: 'data-api', type: 'report', - id: body._id.toString() + id: id }, cb); };