@@ -365,10 +365,13 @@ module.exports = {
365365 else
366366 visibility = "public-data"
367367 console . debug ( visibility )
368- return await Key . find ( {
369- key : { $regex : "^" + search , $options : "i" } ,
368+ let keys = await Key . find ( {
369+ key : { $regex : "^" + search , $options : "i" } ,
370370 visibility
371- } , { "key" : 1 } ) //, { "key": 1, "value": 1, "_id": 0, "visibility":0 })
371+ } , { "key" : 1 , "_id" : 0 } ) //, { "key": 1, "value": 1, "_id": 0, "visibility":0 })
372+ if ( keys . lenght > 500 )
373+ return [ "Too many suggestions. Type some characters in order to reduce them" ]
374+ return keys
372375 } ,
373376
374377 async getValues ( prefix , bucketName , visibility , search ) {
@@ -379,10 +382,13 @@ module.exports = {
379382 else
380383 visibility = "public-data"
381384 console . debug ( visibility )
382- return await Value . find ( {
383- value : { $regex : "^" + search , $options : "i" } ,
385+ let values = await Value . find ( {
386+ value : { $regex : "^" + search , $options : "i" } ,
384387 visibility
385- } , { "value" : 1 } ) //, { "key": 1, "value": 1, "_id": 0, "visibility":0 })
388+ } , { "value" : 1 , "_id" : 0 } ) //, { "key": 1, "value": 1, "_id": 0, "visibility":0 })
389+ if ( values . lenght > 500 )
390+ return [ "Too many suggestions. Type some characters in order to reduce them" ]
391+ return values
386392 } ,
387393
388394 async getEntries ( prefix , bucketName , visibility , searchKey , searchValue ) {
@@ -394,11 +400,14 @@ module.exports = {
394400 else
395401 visibility = "public-data"
396402 console . debug ( visibility )
397- return await Entries . find ( {
398- "key" : { $regex : "^" + searchKey , $options : "i" } ,
399- "value" : { $regex : "^" + searchValue , $options : "i" } ,
403+ let entries = await Entries . find ( {
404+ "key" : { $regex : "^" + searchKey , $options : "i" } ,
405+ "value" : { $regex : "^" + searchValue , $options : "i" } ,
400406 visibility
401- } , { "key" : 1 , "value" : 1 } )
407+ } , { "key" : 1 , "value" : 1 , "_id" : 0 } )
408+ //if (entries.lenght > 500)
409+ // return ["Too many suggestions. Type some characters in order to reduce them"]
410+ return entries
402411 } ,
403412
404413
0 commit comments