MCPcopy Create free account
hub / github.com/53AI/53AIHub / Update

Method Update

api/model/library.go:115–133  ·  view source on GitHub ↗

Update 更新知识库信息

()

Source from the content-addressed store, hash-verified

113
114// Update 更新知识库信息
115func (library *Library) Update() error {
116 if library.Name == "" {
117 return errors.New("library name is required")
118 }
119
120 // 检查名称重复(排除自己)
121 existingLibrary, err := GetLibraryByName(library.SpaceID, library.Name)
122 if err == nil && existingLibrary != nil && existingLibrary.ID != library.ID {
123 return errors.New("library name already exists in this space")
124 }
125
126 // 明确指定要更新的字段,确保零值也能被更新,在原来的基础上加上 Visibility
127 result := DB.Model(library).Select("Name", "Description", "Icon", "SpaceID", "Visibility").Updates(library)
128 if result.Error != nil {
129 return result.Error
130 }
131 invalidateLibraryCache(library.Eid)
132 return nil
133}
134
135func (library *Library) IsPersonalLibrary() bool {
136 return library != nil && library.LibraryKind == LIBRARY_KIND_PERSONAL_USER

Callers

nothing calls this directly

Calls 3

GetLibraryByNameFunction · 0.85
invalidateLibraryCacheFunction · 0.70
NewMethod · 0.45

Tested by

no test coverage detected