package customer import ( "context" "strconv" "time" driver "github.com/arangodb/go-driver" ) const ( DateTemplate string = "2006-01-02" // Шаблон даты TimeTemplate string = "15:04:05" // Шаблон времени StampTemplate string = DateTemplate + " " + TimeTemplate // Шаблон метки времени DateTemplatePast string = "1900-01-01" + " " + TimeTemplate // Далекое прошлое ) type Row struct { ctx context.Context collection driver.Collection database driver.Database key string } // Базовые поля type SimpleRow struct { Row ID string `json:"id"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` DeletedAt string `json:"deleted_at"` } func NewSimpleRow(ctx context.Context, database driver.Database, collection driver.Collection) *SimpleRow { now := time.Now() nowStr := now.Format(StampTemplate) key := strconv.Itoa(now.Nanosecond() * -1) return &SimpleRow{ Row: Row{ ctx: ctx, collection: collection, database: database, key: key, }, ID: key, CreatedAt: nowStr, UpdatedAt: nowStr, DeletedAt: DateTemplatePast, } } // Удаление func (r *SimpleRow) Delete() error { _, err := r.collection.RemoveDocument(r.ctx, r.key) return err }