Browse Source

posts: Fixed AddMany not returning the IDs in the result.

module-madness-pointers
Gisle Aune 6 years ago
parent
commit
2711654816
  1. 4
      models/posts/add-many.go

4
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
}
Loading…
Cancel
Save