Updated BE

This commit is contained in:
Belen Curcio
2017-06-16 16:18:02 -03:00
parent 4403decbe9
commit 991bdc6089
3 changed files with 5 additions and 5 deletions
+2 -3
View File
@@ -22,8 +22,7 @@ const genAssetsByID = (context, ids) => AssetModel.find({
/**
* [getAssetsByQuery description]
* @param {Object} context the context of the request
* @param {String} value text string to search agains the documents
* @param {Number} limit limit the number of results
* @param {Object} query the query
* @return {Promise} resolves the assets
*/
const getAssetsByQuery = (context, query) => {
@@ -76,7 +75,7 @@ module.exports = (context) => ({
// this operation create a new asset if one isn't found.
getByURL: (url) => findOrCreateAssetByURL(context, url),
search: (value, limit) => getAssetsByQuery(context, value, limit),
search: (query) => getAssetsByQuery(context, query),
getByID: new DataLoader((ids) => genAssetsByID(context, ids)),
getForMetrics: () => getAssetsForMetrics(context),
getAll: new util.SingletonResolver(() => AssetModel.find({}))
+2 -2
View File
@@ -48,13 +48,13 @@ router.get('/', (req, res, next) => {
Promise.all([
// Find the actuall assets.
FilterOpenAssets(AssetsService.search(search), filter)
FilterOpenAssets(AssetsService.search({value: search}), filter)
.sort({[field]: (sort === 'asc') ? 1 : -1})
.skip(parseInt(skip))
.limit(parseInt(limit)),
// Get the count of actual assets.
FilterOpenAssets(AssetsService.search(search), filter)
FilterOpenAssets(AssetsService.search({value: search}), filter)
.count()
])
.then(([result, count]) => {
+1
View File
@@ -43,6 +43,7 @@ describe('/api/v1/assets', () => {
.set(passport.inject({roles: ['ADMIN']}))
.then((res) => {
const body = res.body;
console.log(body)
expect(body).to.have.property('count', 2);
expect(body).to.have.property('result');