Skip to content

Commit

Permalink
add entity metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoubfaouzi committed Oct 18, 2024
1 parent f533a09 commit 4fd1cdd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/entity/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

// File represent a binary file.
type File struct {
Meta DocMetadata `json:"doc,omitempty"`
Type string `json:"type,omitempty"`
MD5 string `json:"md5,omitempty"`
SHA1 string `json:"sha1,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions internal/entity/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2018 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.

package entity

// DocMetadata stores metadata information for saved documents in the DB.
type DocMetadata struct {
CreatedAt int64 `json:"created_at,omitempty"`
LastUpdated int64 `json:"last_updated,omitempty"`
Version int `json:"version,omitempty"`
}
1 change: 1 addition & 0 deletions internal/file/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ func (s service) Create(ctx context.Context, req CreateFileRequest) (

// Create a new file.
err = s.repo.Create(ctx, sha256, entity.File{
Meta: entity.DocMetadata{CreatedAt: now, LastUpdated: now, Version: 1},
SHA256: sha256,
Type: "file",
FirstSeen: now,
Expand Down

0 comments on commit 4fd1cdd

Please sign in to comment.