29 lines
1.3 KiB
Go
29 lines
1.3 KiB
Go
|
|
package repository
|
||
|
|
|
||
|
|
import (
|
||
|
|
"go.mongodb.org/mongo-driver/bson"
|
||
|
|
"go.mongodb.org/mongo-driver/mongo"
|
||
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||
|
|
)
|
||
|
|
|
||
|
|
// RunIndexModels is consumed by cmd/init. Keeping index definitions outside
|
||
|
|
// request paths makes startup idempotent and keeps owner-scoped paging fast.
|
||
|
|
func RunIndexModels() []mongo.IndexModel {
|
||
|
|
return []mongo.IndexModel{
|
||
|
|
{Keys: bson.D{{Key: "owner_uid", Value: 1}, {Key: "created_at", Value: -1}, {Key: "_id", Value: -1}}, Options: options.Index().SetName("scout_runs_owner_created")},
|
||
|
|
{Keys: bson.D{{Key: "owner_uid", Value: 1}, {Key: "brand_id", Value: 1}, {Key: "mode", Value: 1}, {Key: "created_at", Value: -1}}, Options: options.Index().SetName("scout_runs_owner_filter")},
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func RunPostIndexModels() []mongo.IndexModel {
|
||
|
|
return []mongo.IndexModel{
|
||
|
|
{Keys: bson.D{{Key: "owner_uid", Value: 1}, {Key: "run_id", Value: 1}, {Key: "score", Value: -1}, {Key: "posted_at", Value: -1}, {Key: "created_at", Value: -1}, {Key: "_id", Value: -1}}, Options: options.Index().SetName("scout_posts_run_score")},
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func SeenIdentityIndexModels() []mongo.IndexModel {
|
||
|
|
return []mongo.IndexModel{
|
||
|
|
{Keys: bson.D{{Key: "owner_uid", Value: 1}, {Key: "identity", Value: 1}}, Options: options.Index().SetName("scout_seen_owner_identity")},
|
||
|
|
}
|
||
|
|
}
|