You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/02/13 03:33:48 UTC

[GitHub] [servicecomb-kie] GuoYL123 commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total

GuoYL123 commented on a change in pull request #93: #92 replace limit/offset by pageNum/pageSize / add param:total
URL: https://github.com/apache/servicecomb-kie/pull/93#discussion_r378635239
 
 

 ##########
 File path: server/service/mongo/history/dao.go
 ##########
 @@ -27,20 +27,22 @@ import (
 	"go.mongodb.org/mongo-driver/mongo/options"
 )
 
-func getHistoryByKeyID(ctx context.Context, filter bson.M, limit, offset int64) ([]*model.KVDoc, error) {
+func getHistoryByKeyID(ctx context.Context, filter bson.M, pageNum, pageSize int64) ([]*model.KVDoc, int, error) {
 	collection := session.GetDB().Collection(session.CollectionKVRevision)
 	opt := options.Find().SetSort(map[string]interface{}{
 		"revision": -1,
 	})
-	if limit != 0 {
-		opt = opt.SetLimit(limit)
+	if pageNum != 0 && pageSize != 0 {
+		opt = opt.SetLimit(pageSize)
+		opt = opt.SetSkip(pageSize * (pageNum - 1))
 	}
-	if offset != 0 {
-		opt = opt.SetSkip(offset)
+	curTotal, errTotal := collection.CountDocuments(ctx, filter)
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services