diff options
| author | Priyansh <[email protected]> | 2025-08-28 13:09:22 +0530 |
|---|---|---|
| committer | Priyansh <[email protected]> | 2025-08-28 13:09:22 +0530 |
| commit | 9e82811a2a963be962fc3ffc426c137e01d56e2d (patch) | |
| tree | 9cde1691f6e8dafb7204b7247dea12af0aa22bf6 /utils/database.go | |
| parent | 18b897a36805d1acb6e2352ca536c1eee9249fe3 (diff) | |
| download | nectar-9e82811a2a963be962fc3ffc426c137e01d56e2d.tar.xz nectar-9e82811a2a963be962fc3ffc426c137e01d56e2d.zip | |
Restructure codebase with proper organization, fix file picker navigation, and add utils packageHEADmain
Diffstat (limited to 'utils/database.go')
| -rw-r--r-- | utils/database.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/utils/database.go b/utils/database.go new file mode 100644 index 0000000..877ec2d --- /dev/null +++ b/utils/database.go @@ -0,0 +1,50 @@ +package utils + +import "nectar/types" + +// GetDefaultPort returns the default port for a given connection type +func GetDefaultPort(connType types.ConnectionType) string { + if port, exists := DefaultPorts[connType]; exists { + return port + } + return "" +} + +// GetFieldCount returns the total number of fields for a connection type +func GetFieldCount(connType types.ConnectionType) int { + if count, exists := FieldCounts[connType]; exists { + return count + } + return 0 +} + +// GetInputIndex returns the input index for a given field based on connection type +func GetInputIndex(connType types.ConnectionType, fieldIndex int) int { + if mapping, exists := FieldMappings[connType]; exists { + if inputIndex, exists := mapping[fieldIndex]; exists { + return inputIndex + } + } + return -1 +} + +// NextConnectionType cycles to the next connection type +func NextConnectionType(current types.ConnectionType) types.ConnectionType { + for i, connType := range ConnectionTypes { + if connType == current { + return ConnectionTypes[(i+1)%len(ConnectionTypes)] + } + } + return current +} + +// PrevConnectionType cycles to the previous connection type +func PrevConnectionType(current types.ConnectionType) types.ConnectionType { + for i, connType := range ConnectionTypes { + if connType == current { + prevIndex := (i - 1 + len(ConnectionTypes)) % len(ConnectionTypes) + return ConnectionTypes[prevIndex] + } + } + return current +} |
