ostafen / clover

A lightweight document-oriented NoSQL database written in pure Golang.
MIT License
666 stars 55 forks source link

How could I get Top 10 #62

Closed ElecTwix closed 2 years ago

ElecTwix commented 2 years ago

Hey, I'm new with NoSQL I'm really excited about it but I couldn't find a way to sort out the just top 10 I could make it with complex functions but I was just wondering is there is an easy way.

Type of Collation in down below, I just want to get a max of 10 playtimes. is there any query for that?

Userid   string `clover:"userid"`
PlayTime int    `clover:"playtime"`
Name     string `clover:"name"`
ostafen commented 2 years ago

Hi, @ElecTwix. Try something like:

db.Query("myCollection").Sort().Limit(10)
ElecTwix commented 2 years ago

That's worked and helped me understand thanks.