From e252d8b740a888e6be1ba3fb889aed7642180c46 Mon Sep 17 00:00:00 2001 From: john Date: Sat, 25 Jul 2020 15:05:08 +0800 Subject: [PATCH] add function ListItemValuesUnique for package gdb --- database/gdb/gdb_func.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/database/gdb/gdb_func.go b/database/gdb/gdb_func.go index 0ee8c9d51..3334acdea 100644 --- a/database/gdb/gdb_func.go +++ b/database/gdb/gdb_func.go @@ -60,12 +60,29 @@ var ( structTagPriority = append([]string{ORM_TAG_FOR_STRUCT}, gconv.StructTagPriority...) ) -// ListItemValues is alias for gutil.ListItemValues. +// ListItemValues retrieves and returns the elements of all item struct/map with key . +// Note that the parameter should be type of slice which contains elements of map or struct, +// or else it returns an empty slice. +// +// The parameter supports types like: +// []map[string]interface{} +// []map[string]sub-map +// []struct +// []struct:sub-struct +// Note that the sub-map/sub-struct makes sense only if the optional parameter is given. // See gutil.ListItemValues. func ListItemValues(list interface{}, key interface{}, subKey ...interface{}) (values []interface{}) { return gutil.ListItemValues(list, key, subKey...) } +// ListItemValuesUnique retrieves and returns the unique elements of all struct/map with key . +// Note that the parameter should be type of slice which contains elements of map or struct, +// or else it returns an empty slice. +// See gutil.ListItemValuesUnique. +func ListItemValuesUnique(list interface{}, key string, subKey ...interface{}) []interface{} { + return gutil.ListItemValuesUnique(list, key, subKey...) +} + // GetInsertOperationByOption returns proper insert option with given parameter