# How to read all objects from postgres storage in Nakama Go lang

**URL:** <https://forum.heroiclabs.com/t/how-to-read-all-objects-from-postgres-storage-in-nakama-go-lang/4429>\
**Category:** Runtime Framework\
**Tags:** golang\
**Created:** [October 5, 2023, 7:14am UTC](https://forum.heroiclabs.com/t/how-to-read-all-objects-from-postgres-storage-in-nakama-go-lang/4429 "2023-10-05T07:14:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpparede](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@rpparede](https://forum.heroiclabs.com/u/rpparede)\
**Post date:** [October 5, 2023, 7:14am UTC](https://forum.heroiclabs.com/t/how-to-read-all-objects-from-postgres-storage-in-nakama-go-lang/4429/1 "2023-10-05T07:14:53Z")

</div>

I’m building a game where each user submits some data from the client to the server. I’m saving this data in Postgres. Once all the players are “ready” in my lobby, I would like to go and pick a random piece of data that was previously submitted by one of my players. However, I’m having trouble to grab all the data from a given collection from the server. I can only read the data to the latest user to call the MatchLoop. As part of the object that I am storing I have a property called “shown”, I would love some help on how to filter for not shown image from the entire collection.

1. Versions: Nakama 3.15.0, Windows| Docker, [GitHub - heroiclabs/nakama-common: The runtime framework for Nakama server.](http://github.com/heroiclabs/nakama-common) v1.26.0
2. Server Framework Runtime language (If relevant) Go

```auto
// Tried not specifying key of userid to read all records from the collection but did not get any data back
objectIds := []*runtime.StorageRead{
	&runtime.StorageRead{
		Collection: "images",
	},
}

// I am currently just reading whatever the last image I get from the latest user to hit MatchLoop
objectIds := []*runtime.StorageRead{
	&runtime.StorageRead{
		Collection: "images",
		Key: matchID,
		UserID: userID,
	},
}

objects, err := nk.StorageRead(ctx, objectIds)

// I'm sending a base 64 of the image from the client directly to the database this is my JS code
      // Upload base64 image to database directly from client
      await ctx.client.writeStorageObjects(ctx.session, [
        {
          "collection": "images",
          "key": matchId,
          "value": data,
        }
      ]).then(async _ =>
        //....
      );

```

📺 **Media:**

---

<div class="post-metadata">

**Author:** ![ftkg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ftkg/32/1180_2.png) [@ftkg](https://forum.heroiclabs.com/u/ftkg)\
**Post date:** [October 5, 2023, 2:22pm UTC](https://forum.heroiclabs.com/t/how-to-read-all-objects-from-postgres-storage-in-nakama-go-lang/4429/2 "2023-10-05T14:22:35Z")

</div>

Hi @rpparede, there’s a function for listing all records in a collection: [StorageList](https://heroiclabs.com/docs/nakama/server-framework/go-runtime/function-reference/#StorageList)

---

<div class="post-metadata">

**Author:** ![rpparede](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@rpparede](https://forum.heroiclabs.com/u/rpparede)\
**Post date:** [October 6, 2023, 6:14am UTC](https://forum.heroiclabs.com/t/how-to-read-all-objects-from-postgres-storage-in-nakama-go-lang/4429/3 "2023-10-06T06:14:21Z")

</div>

@ftkg thanks, I have somehow skipped this function. My question is how can I filter the results I get from StorageList? I would love to only get results that have “shown”: false. I was thinking this would be a good case to write my own postgres query but the docs recommended to check with you first. I can write some code on my server to go through all the objects and find the ones with shown:false but that seems expensive that I have to read all objects everytime.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [October 6, 2023, 9:16am UTC](https://forum.heroiclabs.com/t/how-to-read-all-objects-from-postgres-storage-in-nakama-go-lang/4429/4 "2023-10-06T09:16:20Z")

</div>

Hello @rpparede please have a look at [Heroic Labs Documentation | Storage Search](https://heroiclabs.com/docs/nakama/concepts/storage/search/) I think this will cover your needs.
