From 808509c6ad3515e965fdcc02520c255bec2e0c02 Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Mon, 20 Jul 2020 13:41:54 +0200 Subject: Add index on connection_id in connection_streams --- storage.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/storage.go b/storage.go index b1d2a7d..aced06b 100644 --- a/storage.go +++ b/storage.go @@ -66,6 +66,13 @@ func NewMongoStorage(uri string, port int, database string) (*MongoStorage, erro return nil, err } + if _, err := collections[ConnectionStreams].Indexes().CreateOne(ctx, mongo.IndexModel{ + Keys: bson.D{{"connection_id", -1}}, // descending + Options: options.Index(), + }); err != nil { + return nil, err + } + return &MongoStorage{ client: client, collections: collections, -- cgit v1.2.3-70-g09d2