Compare commits
	
		
			3 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 303bd04649 | |||
| 7bda674939 | |||
| 126d4fbd0b | 
| @@ -15,10 +15,10 @@ func (ee *ExErr) toJson(depth int, applyExtendListener bool, outputMeta bool) la | |||||||
| 		ginJson["id"] = ee.UniqueID | 		ginJson["id"] = ee.UniqueID | ||||||
| 	} | 	} | ||||||
| 	if ee.Category != CatWrap { | 	if ee.Category != CatWrap { | ||||||
| 		ginJson["category"] = ee.Category | 		ginJson["category"] = ee.Category.Category | ||||||
| 	} | 	} | ||||||
| 	if ee.Type != TypeWrap { | 	if ee.Type != TypeWrap { | ||||||
| 		ginJson["type"] = ee.Type | 		ginJson["type"] = ee.Type.Key | ||||||
| 	} | 	} | ||||||
| 	if ee.StatusCode != nil { | 	if ee.StatusCode != nil { | ||||||
| 		ginJson["statuscode"] = ee.StatusCode | 		ginJson["statuscode"] = ee.StatusCode | ||||||
| @@ -30,7 +30,7 @@ func (ee *ExErr) toJson(depth int, applyExtendListener bool, outputMeta bool) la | |||||||
| 		ginJson["caller"] = ee.Caller | 		ginJson["caller"] = ee.Caller | ||||||
| 	} | 	} | ||||||
| 	if ee.Severity != SevErr { | 	if ee.Severity != SevErr { | ||||||
| 		ginJson["severity"] = ee.Severity | 		ginJson["severity"] = ee.Severity.Severity | ||||||
| 	} | 	} | ||||||
| 	if ee.Timestamp != (time.Time{}) { | 	if ee.Timestamp != (time.Time{}) { | ||||||
| 		ginJson["time"] = ee.Timestamp.Format(time.RFC3339) | 		ginJson["time"] = ee.Timestamp.Format(time.RFC3339) | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| package goext | package goext | ||||||
|  |  | ||||||
| const GoextVersion = "0.0.439" | const GoextVersion = "0.0.442" | ||||||
|  |  | ||||||
| const GoextVersionTimestamp = "2024-04-25T11:47:16+0200" | const GoextVersionTimestamp = "2024-04-29T17:24:10+0200" | ||||||
|   | |||||||
| @@ -140,6 +140,42 @@ func (c *Coll[TData]) ListWithCount(ctx context.Context, filter ct.Filter, pageS | |||||||
| 	return data, token, count, nil | 	return data, token, count, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (c *Coll[TData]) ListAllIDs(ctx context.Context, filter ct.RawFilter) ([]string, error) { | ||||||
|  | 	type idObject struct { | ||||||
|  | 		ID string `bson:"_id"` | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	pipelineFilter := mongo.Pipeline{} | ||||||
|  |  | ||||||
|  | 	if filter != nil { | ||||||
|  | 		pipelineFilter = filter.FilterQuery() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	extrModPipelineResolved := mongo.Pipeline{} | ||||||
|  | 	for _, ppl := range c.extraModPipeline { | ||||||
|  | 		extrModPipelineResolved = langext.ArrConcat(extrModPipelineResolved, ppl(ctx)) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	pipelineProjectIDs := mongo.Pipeline{} | ||||||
|  | 	pipelineProjectIDs = append(pipelineProjectIDs, bson.D{{Key: "$project", Value: bson.M{"_id": 1}}}) | ||||||
|  |  | ||||||
|  | 	pipelineList := langext.ArrConcat(pipelineFilter, extrModPipelineResolved, pipelineProjectIDs) | ||||||
|  |  | ||||||
|  | 	cursorList, err := c.coll.Aggregate(ctx, pipelineList) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, exerr.Wrap(err, "mongo-aggregation failed").Any("pipeline", pipelineList).Str("collection", c.Name()).Build() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	var res []idObject | ||||||
|  |  | ||||||
|  | 	err = cursorList.All(ctx, &res) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, exerr.Wrap(err, "failed to decode entities").Any("pipeline", pipelineList).Str("collection", c.Name()).Build() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return langext.ArrMap(res, func(v idObject) string { return v.ID }), nil | ||||||
|  | } | ||||||
|  |  | ||||||
| func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CursorToken, fieldPrimary string, sortPrimary ct.SortDirection, fieldSecondary *string, sortSecondary *ct.SortDirection, pageSize *int) ([]bson.D, []bson.D, error) { | func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CursorToken, fieldPrimary string, sortPrimary ct.SortDirection, fieldSecondary *string, sortSecondary *ct.SortDirection, pageSize *int) ([]bson.D, []bson.D, error) { | ||||||
|  |  | ||||||
| 	cond := bson.A{} | 	cond := bson.A{} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user