Delete 删除资源
(ctx context.Context, collection, key string)
| 404 | |
| 405 | // Delete 删除资源 |
| 406 | func (js *JSONStore) Delete(ctx context.Context, collection, key string) error { |
| 407 | js.mu.Lock() |
| 408 | defer js.mu.Unlock() |
| 409 | |
| 410 | path := filepath.Join(js.collectionDir(collection), key+".json") |
| 411 | if err := os.Remove(path); err != nil { |
| 412 | if os.IsNotExist(err) { |
| 413 | return ErrNotFound |
| 414 | } |
| 415 | return fmt.Errorf("remove file: %w", err) |
| 416 | } |
| 417 | |
| 418 | return nil |
| 419 | } |
| 420 | |
| 421 | // List 列出资源 |
| 422 | func (js *JSONStore) List(ctx context.Context, collection string) ([]any, error) { |
nothing calls this directly
no test coverage detected