2022-01-21 06:48:07 +00:00
|
|
|
package models
|
|
|
|
|
2022-11-27 15:10:45 +00:00
|
|
|
import "encoding/json"
|
|
|
|
|
2022-04-21 07:06:22 +00:00
|
|
|
// Note: any change here should be reflected in providers/casandra/provider.go as it does not have model support in collection creation
|
|
|
|
|
2022-01-21 06:48:07 +00:00
|
|
|
// Session model for db
|
|
|
|
type Session struct {
|
2022-10-02 19:38:12 +00:00
|
|
|
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
|
|
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
2022-10-05 10:02:32 +00:00
|
|
|
UserID string `gorm:"type:char(36)" json:"user_id" bson:"user_id" cql:"user_id" dynamo:"user_id" index:"user_id,hash"`
|
2022-10-02 19:38:12 +00:00
|
|
|
UserAgent string `json:"user_agent" bson:"user_agent" cql:"user_agent" dynamo:"user_agent"`
|
|
|
|
IP string `json:"ip" bson:"ip" cql:"ip" dynamo:"ip"`
|
|
|
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
|
|
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
2022-01-21 06:48:07 +00:00
|
|
|
}
|
2022-11-27 15:10:45 +00:00
|
|
|
|
|
|
|
func (s *Session) ToMap() map[string]interface{} {
|
|
|
|
res := map[string]interface{}{}
|
|
|
|
data, _ := json.Marshal(s) // Convert to a json string
|
|
|
|
json.Unmarshal(data, &res) // Convert to a map
|
|
|
|
return res
|
|
|
|
}
|