Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Use buildProjection utility
Browse files Browse the repository at this point in the history
  • Loading branch information
solocommand committed Jul 22, 2021
1 parent 1f999d7 commit 3dd5907
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { UserInputError } = require('apollo-server-express');

const validateRest = require('../../utils/validate-rest');
const getProjection = require('../../utils/get-projection');
const buildProjection = require('../../utils/build-projection');

const { ObjectID } = MongoDB;

Expand Down Expand Up @@ -163,11 +164,9 @@ module.exports = {
if (input.endDate) body.set('endDate', input.endDate);

const response = await base4rest.insertOne({ model: 'website/schedule', body });
const id = BaseDB.coerceID(response.data.id);

const { fieldNodes, schema, fragments } = info;
const projection = getProjection(schema, schema.getType('WebsiteSchedule'), fieldNodes[0].selectionSet, fragments);
return basedb.findOne('website.Schedule', { _id: id }, { projection });
const { id } = response.data;
const projection = buildProjection({ info, type: 'WebsiteSchedule' });
return basedb.findById('website.Schedule', id, { projection });
},
},
};

0 comments on commit 3dd5907

Please sign in to comment.