MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / Keys

Method Keys

structure/hash.go:1162–1197  ·  view source on GitHub ↗

Keys returns a list of all field names in the hash stored at the specified key. It takes no parameters and returns a slice of strings representing the field names and any possible error. Returns: []string: A list of field names in the hash. error: An error if occurred during the operation, or nil

(regx string)

Source from the content-addressed store, hash-verified

1160// []string: A list of field names in the hash.
1161// error: An error if occurred during the operation, or nil on success.
1162func (hs *HashStructure) Keys(regx string) ([]string, error) {
1163 toRegexp := convertToRegexp(regx)
1164 compile, err := regexp.Compile(toRegexp)
1165 if err != nil {
1166 return nil, err
1167 }
1168 // Get all the keys from the database
1169 byteKeys := hs.db.GetListKeys()
1170
1171 // Create a new slice of strings
1172 keys := make([]string, 0)
1173
1174 for _, key := range byteKeys {
1175 if compile.MatchString(string(key)) {
1176 // Check if the key has the identifier suffix
1177 if !keysIdentify(key) {
1178 fields := hs.GetFields(string(key))
1179 ok := true
1180 for _, field := range fields {
1181 _, err := hs.HGet(string(key), field)
1182 if err != nil {
1183 ok = false
1184 break
1185 }
1186 }
1187 if !ok {
1188 continue
1189 }
1190 keys = append(keys, string(key))
1191 }
1192 }
1193
1194 }
1195
1196 return keys, nil
1197}
1198
1199// GetFields returns a list of all field names in the hash stored at the specified key.
1200// It takes a string key 'k' and returns a slice of strings representing

Callers

nothing calls this directly

Calls 5

GetFieldsMethod · 0.95
HGetMethod · 0.95
convertToRegexpFunction · 0.85
keysIdentifyFunction · 0.85
GetListKeysMethod · 0.80

Tested by

no test coverage detected