# Add data to Post query

**URL:** https://meta.discourse.org/t/add-data-to-post-query/43715
**Category:** Development
**Created:** [May 5, 2016, 8:54am UTC](https://meta.discourse.org/t/add-data-to-post-query/43715 "2016-05-05T08:54:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Andrew\_Byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_byrne/32/116413_2.png) [@Andrew\_Byrne](https://meta.discourse.org/u/Andrew_Byrne)
#### Post date: [May 5, 2016, 8:54am UTC](https://meta.discourse.org/t/add-data-to-post-query/43715/1 "2016-05-05T08:54:47Z")

</div>

ok so I got a lovely query from @tgxworld some time ago.

```
posts = Post.where('user_id IN (?) OR topic_id IN (?) OR raw LIKE (?)', uid, tid, '%@everyone%' )
			 			.order(created_at: :desc)
			                 	.limit(params["total"])
						.offset(params["start"])

```

and it is quite useful, but I ain’t sure how to go adding more data to this.  
What I’m really looking for is a request like above that returns:

- username
- avatar\_template
- like\_count

pretty much what you would find in:

`https://meta.discourse.org/t/19157/1.json`

Any Ideas?

---

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [May 5, 2016, 9:37am UTC](https://meta.discourse.org/t/add-data-to-post-query/43715/2 "2016-05-05T09:37:54Z")

</div>

They are populated by `PostSerializer`. If you use that serializer, they will be already there.

`like_count` for example is included in `actions`.

---

<div class="post-metadata">

### Author: ![Andrew\_Byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_byrne/32/116413_2.png) [@Andrew\_Byrne](https://meta.discourse.org/u/Andrew_Byrne)
#### Post date: [May 6, 2016, 4:22am UTC](https://meta.discourse.org/t/add-data-to-post-query/43715/3 "2016-05-06T04:22:24Z")

</div>

Thank you great pointer!  
My final code ended up looking like:

```
		posts = Post.where('user_id IN (?) OR topic_id IN (?) OR raw LIKE (?)', uid, tid, '%@everyone%' )
		 			.order(created_at: :desc)
		                 	.limit(params["total"])
					.offset(params["start"])

		# that cleaned that up 
		render_json_dump(serialize_data(posts, PostSerializer))

```

And the resulting object contained all that I needed

```
actions_summary: Array[7],
admin:true,
avatar_template:blah/blah.jpg
etc....

```
