aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-07-20 11:41:54 +0000
committerEmiliano Ciavatta2020-07-20 11:41:54 +0000
commit808509c6ad3515e965fdcc02520c255bec2e0c02 (patch)
treeab3c459e773df1c278b901e9a009dbb35c6ace3b
parent1317044508a9b7adf0d4d9faf4b9f75f5834a0c9 (diff)
Add index on connection_id in connection_streams
-rw-r--r--storage.go7
1 files changed, 7 insertions, 0 deletions
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,