Exists 检查资源是否存在
(ctx context.Context, collection, key string)
| 402 | |
| 403 | // Exists 检查资源是否存在 |
| 404 | func (s *MySQLStore) Exists(ctx context.Context, collection, key string) (bool, error) { |
| 405 | var count int64 |
| 406 | if err := s.db.WithContext(ctx).Model(&CollectionItem{}).Where("collection = ? AND `key` = ?", collection, key).Count(&count).Error; err != nil { |
| 407 | return false, err |
| 408 | } |
| 409 | return count > 0, nil |
| 410 | } |
| 411 | |
| 412 | // Close 关闭数据库连接 |
| 413 | func (s *MySQLStore) Close() error { |