refactor: Update models to use DatabaseV2 instead of DataSourceV2

This commit is contained in:
Marvin Zhang
2024-08-05 16:07:19 +08:00
parent e57655c67e
commit 421a06930c
3 changed files with 50 additions and 46 deletions

View File

@@ -1,25 +1,46 @@
package models
import "time"
type DatabaseV2 struct {
any `collection:"databases"`
BaseModelV2[DatabaseV2] `bson:",inline"`
Name string `json:"name" bson:"name"`
DataSource string `json:"data_source" bson:"data_source"`
Type string `json:"type" bson:"type"`
Description string `json:"description" bson:"description"`
Host string `json:"host" bson:"host"`
Port int `json:"port" bson:"port"`
Url string `json:"url" bson:"url"`
Database string `json:"database" bson:"database"`
Username string `json:"username" bson:"username"`
Password string `json:"-,omitempty" bson:"password"`
ConnectType string `json:"connect_type" bson:"connect_type"`
Status string `json:"status" bson:"status"`
Error string `json:"error" bson:"error"`
Extra map[string]string `json:"extra,omitempty" bson:"extra,omitempty"`
Name string `json:"name" bson:"name"`
DataSource string `json:"data_source" bson:"data_source"`
Type string `json:"type" bson:"type"`
Description string `json:"description" bson:"description"`
Host string `json:"host" bson:"host"`
Port int `json:"port" bson:"port"`
URI string `json:"uri,omitempty" bson:"uri,omitempty"`
Database string `json:"database,omitempty" bson:"database,omitempty"`
Username string `json:"username,omitempty" bson:"username,omitempty"`
Password string `json:"-,omitempty" bson:"password,omitempty"`
ConnectType string `json:"connect_type,omitempty" bson:"connect_type,omitempty"`
Status string `json:"status" bson:"status"`
Error string `json:"error" bson:"error"`
Active bool `json:"active" bson:"active"`
ActiveAt time.Time `json:"active_ts" bson:"active_ts"`
MongoParams *struct {
AuthSource string `json:"auth_source,omitempty" bson:"auth_source,omitempty"`
AuthMechanism string `json:"auth_mechanism,omitempty" bson:"auth_mechanism,omitempty"`
} `json:"mongo_params,omitempty" bson:"mongo_params,omitempty"`
PostgresParams *struct {
SSLMode string `json:"ssl_mode,omitempty" bson:"ssl_mode,omitempty"`
} `json:"postgres_params,omitempty" bson:"postgres_params,omitempty"`
SnowflakeParams *struct {
Account string `json:"account,omitempty" bson:"account,omitempty"`
Schema string `json:"schema,omitempty" bson:"schema,omitempty"`
Warehouse string `json:"warehouse,omitempty" bson:"warehouse,omitempty"`
Role string `json:"role,omitempty" bson:"role,omitempty"`
} `json:"snowflake_params,omitempty" bson:"snowflake_params,omitempty"`
CassandraParams *struct {
Keyspace string `json:"keyspace,omitempty" bson:"keyspace,omitempty"`
}
HiveParams *struct {
Auth string `json:"auth,omitempty" bson:"auth,omitempty"`
}
RedisParams *struct {
DB int `json:"db,omitempty" bson:"db,omitempty"`
}
}