Skip to content

Commit 3eba7f4

Browse files
committed
added the enabled field in db config
1 parent b2198a2 commit 3eba7f4

File tree

6 files changed

+10
-0
lines changed

6 files changed

+10
-0
lines changed

Diff for: config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type CrudStub struct {
3939
Conn string `json:"conn" yaml:"conn"`
4040
Collections map[string]*TableRule `json:"collections" yaml:"collections"` // The key here is table name
4141
IsPrimary bool `json:"isPrimary" yaml:"isPrimary"`
42+
Enabled bool `json:"enabled" yaml:"enabled"`
4243
}
4344

4445
// TableRule contains the config at the collection level

Diff for: config/template.go

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ secret: some-secret
66
modules:
77
crud:
88
{{.PrimaryDB}}:
9+
enabled: true
910
conn: {{.Conn}}
1011
isPrimary: true
1112
collections:

Diff for: examples/basic-todo-app/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ secret: some-secret
44
modules:
55
crud:
66
mongo:
7+
enabled: true
78
conn: mongodb://localhost:27017
89
collections:
910
todos:

Diff for: examples/realtime-monitoring-app/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ modules:
1717
rule: allow
1818
crud:
1919
sql-mysql:
20+
enabled: true
2021
conn: root:my-secret-pw@/test_database
2122
isPrimary: true
2223
collections:

Diff for: examples/realtime-todo-app/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ secret: some-secret
44
modules:
55
crud:
66
mongo:
7+
enabled: true
78
conn: mongodb://localhost:27017
89
isPrimary: true
910
collections:

Diff for: modules/crud/crud.go

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ func (m *Module) SetConfig(crud config.Crud) error {
8484

8585
// Create a new crud blocks
8686
for k, v := range crud {
87+
// Skip this block if it is not enabled
88+
if !v.Enabled {
89+
continue
90+
}
91+
8792
c, err := initBlock(utils.DBType(k), v.Conn)
8893
if err != nil {
8994
return errors.New("CURD: Error - " + k + " could not be initialised")

0 commit comments

Comments
 (0)