asdine / storm

Simple and powerful toolkit for BoltDB
MIT License
2.06k stars 139 forks source link

OrderBy not working correctly #247

Closed artvel closed 5 years ago

artvel commented 5 years ago

Reproducible with time.Time and Select with or without q.Re and with or without Reverse().

    Item struct {
        ID     string `json:"id" storm:"id"`
        Name   string `json:"name" storm:"index"`
        Detail string `json:"detail"`
        Updated time.Time `json:"updated" storm:"index"`
        Created time.Time `json:"created" storm:"index"`
    }

func queryAll(contains string) ([]*Item, error){
    var items []*Item
    db.Select(q.Or(
    q.Re("Name", contains),
    q.Re("Detail", contains))).Limit(20).
    Skip(10).
    OrderBy("Created").
    Reverse().
    Find(&items)
    return items, nil
}

Any help appreciated.

Thanks!

artvel commented 5 years ago

@asdine any chance that this is going to be considered? Let me know, in case I can be of any help.

gnur commented 5 years ago

I just ran into this exact issue, great to see there already is an PR addressing it, much cleaner then making an additional string timestamp column to sort on.

asdine commented 5 years ago

Thank you @artvel, sorry for the delay :pray: