go-queryset icon indicating copy to clipboard operation
go-queryset copied to clipboard

Support aggregations and selecting only some fields

Open jirfag opened this issue 7 years ago • 0 comments

Now we write:

	db := ctx.GetGorm().
		Select("max("+PointDBSchema.TripPointID.String()+") as max_id, "+
			"count("+PointDBSchema.PlaceID.String()+") as rating").
		Where(PointDBSchema.LocationID.String()+" = ?", locationID).
		Group(PointDBSchema.PlaceID.String()).
		Order("rating DESC").
		Limit(limit)

jirfag avatar Nov 03 '17 08:11 jirfag