remove source
This commit is contained in:
parent
3af9a2a41a
commit
ae9b4cd9c4
|
@ -29,7 +29,6 @@ func (s Service) Create(payload CreatePayload) {
|
|||
// Get document
|
||||
doc := Audit{
|
||||
ID: mongodb.NewObjectID(),
|
||||
Source: s.Source,
|
||||
Target: payload.Target,
|
||||
TargetID: payload.TargetID,
|
||||
Action: payload.Action,
|
||||
|
|
|
@ -26,7 +26,6 @@ func (s Service) All(query AllQuery) []Audit {
|
|||
|
||||
// Find db
|
||||
cursor, err := s.DB.Collection(colName).Find(ctx, bson.D{
|
||||
{"source", s.Source},
|
||||
{"target", query.Target},
|
||||
{"targetId", query.TargetID},
|
||||
}, &options.FindOptions{
|
||||
|
|
6
audit.go
6
audit.go
|
@ -15,8 +15,6 @@ type MongoDBConfig struct {
|
|||
|
||||
// Config ...
|
||||
type Config struct {
|
||||
// Source of server, e.g: selly
|
||||
Source string
|
||||
// Targets: staff, article, ...
|
||||
Targets []string
|
||||
// MongoDB config, for save documents
|
||||
|
@ -33,8 +31,8 @@ var s *Service
|
|||
|
||||
// NewInstance ...
|
||||
func NewInstance(config Config) error {
|
||||
if config.Source == "" || len(config.Targets) == 0 || config.MongoDB.Host == "" {
|
||||
return errors.New("please provide all necessary information: source, targets, mongodb")
|
||||
if len(config.Targets) == 0 || config.MongoDB.Host == "" {
|
||||
return errors.New("please provide all necessary information: targets, mongodb")
|
||||
}
|
||||
|
||||
// Connect MongoDB
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package audit
|
||||
|
||||
// List actions
|
||||
const (
|
||||
ActionCreate = "create"
|
||||
ActionUpdate = "update"
|
||||
ActionUpdatePermissions = "update-permissions"
|
||||
)
|
|
@ -6,9 +6,9 @@ import (
|
|||
|
||||
func (s Service) indexDB() {
|
||||
// Index key
|
||||
commonIndex := mongodb.NewIndexKey("source", "target", "targetId")
|
||||
commonIndex := mongodb.NewIndexKey("target", "targetId")
|
||||
|
||||
// Index all allowed sources
|
||||
// Index all targets
|
||||
for _, target := range s.Targets {
|
||||
mongodb.CreateIndex(getColName(target), commonIndex)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
// Audit ...
|
||||
type Audit struct {
|
||||
ID primitive.ObjectID `bson:"_id" json:"id"`
|
||||
Source string `bson:"source" json:"source"`
|
||||
Target string `bson:"target" json:"target"`
|
||||
TargetID string `bson:"targetId" json:"targetId"`
|
||||
Action string `bson:"action" json:"action"`
|
||||
|
|
Loading…
Reference in New Issue