From 491d6cab0bfc1b485dd3d6d93da945c25c465cd6 Mon Sep 17 00:00:00 2001 From: Genert Org Date: Sat, 29 May 2021 16:04:16 +0300 Subject: [PATCH] fix: keep 0 value for "expireAfter" option This commit fixes issue described in PR #291 --- collection_indexes_impl.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collection_indexes_impl.go b/collection_indexes_impl.go index fd8c4efc..b5c6077c 100644 --- a/collection_indexes_impl.go +++ b/collection_indexes_impl.go @@ -38,7 +38,7 @@ type indexData struct { InBackground *bool `json:"inBackground,omitempty"` Estimates *bool `json:"estimates,omitempty"` MinLength int `json:"minLength,omitempty"` - ExpireAfter int `json:"expireAfter,omitempty"` + ExpireAfter *int `json:"expireAfter,omitempty"` Name string `json:"name,omitempty"` } @@ -255,7 +255,7 @@ func (c *collection) EnsureTTLIndex(ctx context.Context, field string, expireAft input := indexData{ Type: string(TTLIndex), Fields: []string{field}, - ExpireAfter: expireAfter, + ExpireAfter: &expireAfter, } if options != nil { input.InBackground = &options.InBackground