Skip to content

Commit

Permalink
expose JSON map
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancisZamora committed Jul 9, 2018
1 parent 2520d4b commit 960cf0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions server/anchor/hapi-anchor-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ const register = async function (server, options) {

const models = await readDir(Path.join(__dirname,modelPath));

const anchorModels = models.reduce((accumulator, file) => {
const [anchorModels, collectionModels] = models.reduce((accumulator, file) => {

const model = require(Path.join(__dirname,modelPath,file));
if (model.prototype instanceof AnchorModel) {
accumulator.push(model);
accumulator[0].push(model);
accumulator[1][model.collectionName] = model;
}
return accumulator;
},[]);
},[[],{}]);

server.expose('anchor-model', AnchorModel);
server.expose('models', anchorModels);

server.expose('models',collectionModels);
server.expose('anchorModel', AnchorModel);
server.expose('modelsArray', anchorModels);

server.ext({
type: 'onPreStart',
Expand Down
2 changes: 1 addition & 1 deletion server/models/analytic.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Analytic.payload = Joi.object({

Analytic.indexes = [
{ key: { event: 1 } },
{ key : { email: 1 } }
{ key : { name: 1 } }
];

module.exports = Analytic;
Expand Down

0 comments on commit 960cf0d

Please sign in to comment.