Alan Colon 7 anni fa
parent
commit
28450b2280
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      lib/util.js

+ 4 - 1
lib/util.js

@@ -30,10 +30,13 @@ const sanitize = _.curry(async (req, data) => {
   return data
 })
 
-const dict = (collection) => {
+const dict = (collection, fields) => {
   collection.forEach(item => {
     collection[item.key] = item
     collection[item.id] = item
+    if (Array.isArray(fields)) {
+      fields.forEach(field => collection[item[field]] = field)
+    }
   })
   return collection
 }