fix: unique constraint data

This commit is contained in:
Lakhan Samani
2021-12-22 15:31:45 +05:30
parent 508c714932
commit 3ee79c3937
21 changed files with 206 additions and 192 deletions

View File

@@ -10,8 +10,7 @@ import (
)
type Session struct {
Key string `json:"_key,omitempty" bson:"_key,omitempty"` // for arangodb
// ObjectID string `json:"_id,omitempty" bson:"_id"` // for arangodb & mongodb
Key string `json:"_key,omitempty" bson:"_key,omitempty"` // for arangodb
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id"`
UserID string `gorm:"type:char(36)" json:"user_id" bson:"user_id"`
User User `json:"-" bson:"-"`
@@ -29,7 +28,6 @@ func (mgr *manager) AddSession(session Session) error {
if IsORMSupported {
session.Key = session.ID
// session.ObjectID = session.ID
res := mgr.sqlDB.Clauses(
clause.OnConflict{
DoNothing: true,
@@ -53,7 +51,6 @@ func (mgr *manager) AddSession(session Session) error {
if IsMongoDB {
session.Key = session.ID
// session.ObjectID = session.ID
session.CreatedAt = time.Now().Unix()
session.UpdatedAt = time.Now().Unix()
sessionCollection := mgr.mongodb.Collection(Collections.Session, options.Collection())