Re-wrote parenting, should be significantly faster, more maintainable
This commit is contained in:
12
app/imports/api/parenting/fetchDocByRef.js
Normal file
12
app/imports/api/parenting/fetchDocByRef.js
Normal file
@@ -0,0 +1,12 @@
|
||||
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});
|
||||
};
|
||||
Reference in New Issue
Block a user