Skip to content

Commit

Permalink
more explicit error message
Browse files Browse the repository at this point in the history
  • Loading branch information
touv committed Dec 6, 2024
1 parent 01410ef commit afa4ed5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/ezsLodex/src/precomputedSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import set from 'lodash/set';
import mongoDatabase from './mongoDatabase';

/**
* Take `Object` containing a MongoDB query and throw the result
* Take `Object` Request to precomputed collection
*
* The input object must contain a `connectionStringURI` property, containing
* the connection string to MongoDB.
*
* @name LodexRunQuery
* @param {String} [collection="publishedDataset"] collection to use
* @name LodexPRecomputedSelect
* @param {String} [path=value] Default path to set result
* @param {Object} [filter] MongoDB filter
* @param {Object} [limit] limit the result
* @param {Object} [skip] limit the result
* @param {Number} [limit] limit the result
* @param {Number} [skip] skip the result
* @returns {Object}
*/
export const createFunction = () =>
Expand All @@ -35,6 +33,9 @@ export const createFunction = () =>
.collection('precomputed')
.find({ name: precomputedName })
.toArray();
if (!precomputedObject || !precomputedObject._id) {
return feed.stop(new Error(`${precomputedName} is unknown`));
}
const collectionName = `pc_${precomputedObject._id.toString()}`;

const collection = db.collection(collectionName);
Expand Down

0 comments on commit afa4ed5

Please sign in to comment.