Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 850 Bytes

README.md

File metadata and controls

44 lines (35 loc) · 850 Bytes

#Overview

this is ORM library for query data inside CSV file

Installation :

go get github.com/Rhyanz46/SimpleCsv

Example :

  • Create new data
type ShareLocTime struct {
    Imei         string
    TimeInMinute string
    From         time.Time
    To           time.Time
}

csvData := SimpleCsv.NewCsvData(SimpleCsv.BaseData{
    Location: "./data.csv",
    Struct:   ShareLocTime{},
})
  • Select Query
var result ShareLocTime
now := time.Now().Format(time.RFC3339)
whereTo := SimpleCsv.Where{Field: "To", Operator: ">", Value: fmt.Sprintf("%v", now)}
whereImei := SimpleCsv.Where{Field: "Imei", Operator: "=", Value: imei}
err := csvData.Select("To").WhereValue(whereTo, "and", whereImei).One(&result)

if err != nil {
    if err.Error() == SimpleCsv.NO_RESULT {
        ....
    }
    return
}

fmt.println(result)