Files
DiceCloud/app/imports/api/parenting/fetchDocByRef.js
2019-07-30 13:07:31 +02:00

13 lines
429 B
JavaScript

import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
const docNotFoundError = function({id, collection}){
throw new Meteor.Error('document-not-found',
`No document could be found with id: ${id} in ${collection}`
);
};
export default function fetchDocByRef({id, collection}, options){
return getCollectionByName(collection).findOne(id, options) ||
docNotFoundError({id, collection});
}