mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-14 04:04:23 +00:00
Indexer accepts arbitrary key to index by. Fix bug: Return an object instead of an array.
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
|
||||
angular.module("ofn.admin").factory 'Indexer', ->
|
||||
new class Indexer
|
||||
index: (data) ->
|
||||
index = []
|
||||
index: (data, key='id') ->
|
||||
index = {}
|
||||
for e in data
|
||||
index[e.id] = e
|
||||
index[e[key]] = e
|
||||
index
|
||||
|
||||
Reference in New Issue
Block a user