Files
DiceCloud/app/imports/api/creature/parenting/fetchDocByRef.js
2019-04-15 12:09:37 +02:00

13 lines
438 B
JavaScript

import getCollectionByName from '/imports/api/creature/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});
}