MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / DeleteCheck

Method DeleteCheck

agent/app/service/database_mongodb.go:226–262  ·  view source on GitHub ↗
(req dto.MongodbDBDeleteCheck)

Source from the content-addressed store, hash-verified

224}
225
226func (u *MongodbService) DeleteCheck(req dto.MongodbDBDeleteCheck) ([]dto.DBResource, error) {
227 var res []dto.DBResource
228 db, err := mongodbRepo.Get(repo.WithByID(req.ID))
229 if err != nil {
230 return res, err
231 }
232
233 if db.From == "local" {
234 app, err := appInstallRepo.LoadBaseInfo(req.Type, req.Database)
235 if err != nil {
236 return res, err
237 }
238 apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(app.ID), appInstallResourceRepo.WithResourceId(db.ID))
239 for _, app := range apps {
240 appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(app.AppInstallId))
241 if appInstall.ID != 0 {
242 res = append(res, dto.DBResource{
243 Type: constant.TypeApp,
244 Name: appInstall.Name,
245 })
246 }
247 }
248 } else {
249 apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithResourceId(db.ID), appRepo.WithKey(req.Type))
250 for _, app := range apps {
251 appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(app.AppInstallId))
252 if appInstall.ID != 0 {
253 res = append(res, dto.DBResource{
254 Type: constant.TypeApp,
255 Name: appInstall.Name,
256 })
257 }
258 }
259 }
260
261 return res, nil
262}
263
264func (u *MongodbService) LoadPrivileges(req dto.MongodbPrivilegesLoad) (string, error) {
265 dbItem, err := mongodbRepo.Get(mongodbRepo.WithByMongodbName(req.Database), repo.WithByName(req.Name))

Callers

nothing calls this directly

Calls 8

GetMethod · 0.65
WithByIDMethod · 0.65
LoadBaseInfoMethod · 0.65
GetByMethod · 0.65
WithLinkIdMethod · 0.65
WithResourceIdMethod · 0.65
GetFirstMethod · 0.65
WithKeyMethod · 0.65

Tested by

no test coverage detected