MCPcopy Create free account
hub / github.com/Masterminds/structable / Exists

Method Exists

structable.go:350–358  ·  view source on GitHub ↗

Exists returns `true` if and only if there is at least one record that matches the primary keys for this Record. If the primary key on the Record has no value, this will look for records with no value (or the default value).

()

Source from the content-addressed store, hash-verified

348// If the primary key on the Record has no value, this will look for records with no value (or the default
349// value).
350func (s *DbRecorder) Exists() (bool, error) {
351 has := false
352 whereParts := s.whereIds()
353
354 q := s.builder.Select("COUNT(*) > 0").From(s.table).Where(whereParts)
355 err := q.QueryRow().Scan(&has)
356
357 return has, err
358}
359
360// ExistsWhere returns `true` if and only if there is at least one record that matches one (or multiple) conditions.
361//

Callers

nothing calls this directly

Calls 3

whereIdsMethod · 0.95
ScanMethod · 0.80
QueryRowMethod · 0.80

Tested by

no test coverage detected