From 2711654816aa08bf6cdfc883daed497aff2cdb8f Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Wed, 5 Dec 2018 20:58:37 +0100 Subject: [PATCH] posts: Fixed AddMany not returning the IDs in the result. --- models/posts/add-many.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/posts/add-many.go b/models/posts/add-many.go index ceb8f3f..e642c9d 100644 --- a/models/posts/add-many.go +++ b/models/posts/add-many.go @@ -8,6 +8,7 @@ import ( // AddMany adds multiple posts in on query. Each post gets a new ID and is associated with the log. func AddMany(log models.Log, posts []models.Post) ([]models.Post, error) { docs := make([]interface{}, len(posts)) + copies := make([]models.Post, len(posts)) mutex.RLock() defer mutex.RUnlock() @@ -23,6 +24,7 @@ func AddMany(log models.Log, posts []models.Post) ([]models.Post, error) { post.Position = startPosition + i docs[i] = post + copies[i] = post } err = collection.Insert(docs...) @@ -30,5 +32,5 @@ func AddMany(log models.Log, posts []models.Post) ([]models.Post, error) { return nil, err } - return posts, nil + return copies, nil }