added time
This commit is contained in:
parent
f89589d0db
commit
426a4cbd83
@ -3,7 +3,6 @@ package repo
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.icod.de/dalu/refdata/model"
|
"git.icod.de/dalu/refdata/model"
|
||||||
@ -200,6 +199,30 @@ func (r *DataRepository) List(p *DataParams) ([]*model.Data, error) {
|
|||||||
q["enabled"] = p.EnabledQuery.Query
|
q["enabled"] = p.EnabledQuery.Query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// time
|
||||||
|
if p.When {
|
||||||
|
switch p.WhenQuery.Operation {
|
||||||
|
case "eq":
|
||||||
|
q["when"] = p.WhenQuery.From
|
||||||
|
case "gt":
|
||||||
|
q["when"] = bson.M{"$gt": p.WhenQuery.From}
|
||||||
|
case "gte":
|
||||||
|
q["when"] = bson.M{"$gte": p.WhenQuery.From}
|
||||||
|
case "lt":
|
||||||
|
q["when"] = bson.M{"$lt": p.WhenQuery.To}
|
||||||
|
case "lte":
|
||||||
|
q["when"] = bson.M{"$lte": p.WhenQuery.To}
|
||||||
|
case "gt-lt":
|
||||||
|
q["when"] = bson.M{"$gt": p.WhenQuery.From, "$lt": p.WhenQuery.To}
|
||||||
|
case "gte-lte":
|
||||||
|
q["when"] = bson.M{"$gte": p.WhenQuery.From, "$lte": p.WhenQuery.To}
|
||||||
|
case "gte-lt":
|
||||||
|
q["when"] = bson.M{"$gte": p.WhenQuery.From, "$lt": p.WhenQuery.To}
|
||||||
|
case "gt-lte":
|
||||||
|
q["when"] = bson.M{"$gt": p.WhenQuery.From, "$lte": p.WhenQuery.To}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var m []*model.Data
|
var m []*model.Data
|
||||||
rq := c.Find(q)
|
rq := c.Find(q)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user