service backend
This commit is contained in:
39
api/pkg/db/storable/id.go
Normal file
39
api/pkg/db/storable/id.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package storable
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
const (
|
||||
IDField = "_id"
|
||||
PermissionRefField = "permissionRef"
|
||||
OrganizationRefField = "organizationRef"
|
||||
IsArchivedField = "isArchived"
|
||||
UpdatedAtField = "updatedAt"
|
||||
)
|
||||
|
||||
type Base struct {
|
||||
ID primitive.ObjectID `bson:"_id" json:"id"`
|
||||
CreatedAt time.Time `bson:"createdAt" json:"createdAt"` // Timestamp for when the comment was created
|
||||
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"` // Timestamp for when the comment was last updated (optional)
|
||||
}
|
||||
|
||||
func (b *Base) GetID() *primitive.ObjectID {
|
||||
return &b.ID
|
||||
}
|
||||
|
||||
func (b *Base) SetID(objID primitive.ObjectID) {
|
||||
b.ID = objID
|
||||
b.CreatedAt = time.Now()
|
||||
b.UpdatedAt = time.Now()
|
||||
}
|
||||
|
||||
func (b *Base) Update() {
|
||||
b.UpdatedAt = time.Now()
|
||||
}
|
||||
|
||||
func (b *Base) Collection() string {
|
||||
return "base"
|
||||
}
|
||||
11
api/pkg/db/storable/ref.go
Normal file
11
api/pkg/db/storable/ref.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package storable
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
||||
const (
|
||||
RefField = "ref"
|
||||
)
|
||||
|
||||
type Ref struct {
|
||||
Ref primitive.ObjectID `bson:"ref" json:"ref"`
|
||||
}
|
||||
10
api/pkg/db/storable/storable.go
Normal file
10
api/pkg/db/storable/storable.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package storable
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
||||
type Storable interface {
|
||||
GetID() *primitive.ObjectID
|
||||
SetID(objID primitive.ObjectID)
|
||||
Update()
|
||||
Collection() string
|
||||
}
|
||||
Reference in New Issue
Block a user