# Enrichment

### Enrichment of Collection Entries

Objects stored inside collections can be embedded inside activities or user objects. This allows you to integrate with Stream without building a complex integration with another database.
Stream's collections can be used as your data source for data enrichment.

<Tabs>

```csharp label="C#"
// first we add our object to the food collection
var collectionData = new Dictionary<string, object>();
collectionData.Add("name", "Cheese Burger");
collectionData.Add("ingredients", new[] { "cheese", "burger", "bread", "lettuce", "tomato" });
var cheeseBurger = await client.Collections.AddAsync("food", collectionData, "123");

// the object returned by .add can be embedded directly inside of an activity
var activity = new Activity("jim", "grill", cheeseBurger.Ref("food"));
await userFeed.AddActivityAsync(activity);

// if we now read the feed, the activity we just added will include the entire full object
await userFeed.GetEnrichedFlatActivitiesAsync();
```

```js label="JavaScript"
// first we add our object to the food collection
let cheeseBurger = await client.collections.add("food", "123", {
  name: "Cheese Burger",
  ingredients: ["cheese", "burger", "bread", "lettuce", "tomato"],
});

// the object returned by .add can be embedded directly inside of an activity
await userFeed.addActivity({
  actor: client.currentUser,
  verb: "grill",
  object: cheeseBurger,
});

// if we now read the feed, the activity we just added will include the entire full object
await userFeed.get();

// we can then update the object and Stream will propagate the change to all activities
await cheeseBurger.update({
  name: "Amazing Cheese Burger",
  ingredients: ["cheese", "burger", "bread", "lettuce", "tomato"],
});
```

```python label="Python"
# first we add our object to the food collection
cheese_burger = client.collections.add(
  "food",
  data={
    "name": "Cheese Burger",
    "ingredients": ["cheese", "burger", "bread", "lettuce", "tomato"],
  },
)

# then we embed a reference to the entry we created before
user_feed.add_activity(
  {
    "actor": "jim",
    "verb": "grill",
    "object": client.collections.create_reference(
      "food", cheese_burger["id"]
    ),
  }
)

# if we now read the feed, the activity we just added will include the entire full object
user_feed.get(enrich=True)
```

```ruby label="Ruby"
# first we add our object to the food collection
cheese_burger = client.collections.add(
  "food",
  :data =&gt; {
    :name =&gt; "Cheese Burger",
    :ingredients =&gt; ["cheese", "burger", "bread", "lettuce", "tomato"],
  },
)

# then we embed a reference to the entry we created before
user_feed.add_activity({
  :actor =&gt; "jim",
  :verb =&gt; "grill",
  :object =&gt; client.collections.create_reference(
    "food", cheese_burger["id"]
  ),
})

# if we now read the feed, the activity we just added will include the entire full object
user_feed.get(:enrich =&gt; true)
```

```php label="PHP"
// first we add our object to the food collection
$client-&gt;collections()-&gt;add(
   "food", ["name" =&gt; "Cheese Burger", "rating" =&gt; "4 stars"], "cheese-burger"
);

// then we embed a reference to the entry we created before
$user_feed-&gt;addActivity(
  ["actor" =&gt; "jim", "verb" =&gt; "grill",
   "object" =&gt; $client-&gt;collections()-&gt;createReference("food", "cheese-burger")]
);

// if we now read the feed, the activity we just added will include the entire full object
$user_feed-&gt;getActivities(0, 1, null, true);
```

```java label="Java"
// first we add our object to the food collection
CollectionData cheeseBurger = client.collections().add("food", new CollectionData("123")
    .set("name", "Cheese Burger")
    .set("ingredients", Lists.newArrayList("cheese", "burger", "bread", "lettuce", "tomato"))).join();

// the object returned by .add can be embedded directly inside of an activity
userFeed.addActivity(Activity.builder()
    .actor(createUserReference("john-doe"))
    .verb("grill")
    .object(createCollectionReference(cheeseBurger.getCollection(), cheeseBurger.getID()))
    .build()).join();

// if we now read the feed, the activity we just added will include the entire full object
userFeed.getEnrichedActivities();

// we can then update the object and Stream will propagate the change to all activities
client.collections().update(cheeseBurger.getCollection(), cheeseBurger
    .set("name", "Amazing Cheese Burger")
    .set("ingredients", Lists.newArrayList("cheese", "burger", "bread", "lettuce", "tomato"))).join();
```

```go label="Go"
//first we add our object to the food collection
	obj := stream.CollectionObject{
		Data: map[string]any{
			"name":    "Cheese Burger",
			"ingredients": []string{"cheese", "burger", "bread", "lettuce", "tomato"},
		},
	}
	resp, err := client.Collections().Add(context.TODO(), "food", obj)
	if err != nil {
		panic(err)
	}

	// then we embed a reference to the entry we created before
	activity := stream.Activity{
		Actor: "jim",
		Verb:  "grill",
		Object: client.Collections().CreateReference("food", resp.ID),
	}
	_, err := userFeed.AddActivity(context.TODO(), activity)
	if err != nil {
		panic(err)
	}

	// if we now read the feed, the activity we just added will include the entire full object
	resp, err := userFeed.GetEnrichedActivities(context.TODO())
	if err != nil {
		panic(err)
	}
```

</Tabs>


---

This page was last updated at 2026-05-22T16:31:48.188Z.

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/node/v2/collections-enrichment/](https://getstream.io/activity-feeds/docs/node/v2/collections-enrichment/).