mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: Update models to use DatabaseV2 instead of DataSourceV2
The code changes update the models and related functions to use the new DatabaseV2 struct instead of the deprecated DataSourceV2 struct. This change ensures consistency and clarity in the codebase.
This commit is contained in:
@@ -82,7 +82,7 @@ func CreateIndexesV2() {
|
||||
})
|
||||
|
||||
// data sources
|
||||
mongo.GetMongoCol(service.GetCollectionNameByInstance(models2.DataSourceV2{})).MustCreateIndexes([]mongo2.IndexModel{
|
||||
mongo.GetMongoCol(service.GetCollectionNameByInstance(models2.DatabaseV2{})).MustCreateIndexes([]mongo2.IndexModel{
|
||||
{Keys: bson.M{"name": 1}},
|
||||
})
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package models
|
||||
|
||||
type DataSourceV2 struct {
|
||||
any `collection:"data_sources"`
|
||||
BaseModelV2[DataSourceV2] `bson:",inline"`
|
||||
Name string `json:"name" bson:"name"`
|
||||
Type string `json:"type" bson:"type"`
|
||||
Description string `json:"description" bson:"description"`
|
||||
Host string `json:"host" bson:"host"`
|
||||
Port string `json:"port" bson:"port"`
|
||||
Url string `json:"url" bson:"url"`
|
||||
Hosts []string `json:"hosts" bson:"hosts"`
|
||||
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"`
|
||||
}
|
||||
20
core/models/models/v2/database_v2.go
Normal file
20
core/models/models/v2/database_v2.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package models
|
||||
|
||||
type DatabaseV2 struct {
|
||||
any `collection:"databases"`
|
||||
BaseModelV2[DatabaseV2] `bson:",inline"`
|
||||
Name string `json:"name" bson:"name"`
|
||||
Type string `json:"type" bson:"type"`
|
||||
Description string `json:"description" bson:"description"`
|
||||
Host string `json:"host" bson:"host"`
|
||||
Port string `json:"port" bson:"port"`
|
||||
Url string `json:"url" bson:"url"`
|
||||
Hosts []string `json:"hosts" bson:"hosts"`
|
||||
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"`
|
||||
}
|
||||
@@ -11,7 +11,7 @@ type SpiderV2 struct {
|
||||
ColId primitive.ObjectID `json:"col_id" bson:"col_id"` // data collection id
|
||||
ColName string `json:"col_name,omitempty" bson:"-"` // data collection name
|
||||
DataSourceId primitive.ObjectID `json:"data_source_id" bson:"data_source_id"` // data source id
|
||||
DataSource *DataSourceV2 `json:"data_source,omitempty" bson:"-"` // data source
|
||||
DataSource *DatabaseV2 `json:"data_source,omitempty" bson:"-"` // data source
|
||||
Description string `json:"description" bson:"description"` // description
|
||||
ProjectId primitive.ObjectID `json:"project_id" bson:"project_id"` // Project.Id
|
||||
Mode string `json:"mode" bson:"mode"` // default Task.Mode
|
||||
|
||||
Reference in New Issue
Block a user