# Aerospike Chat

**URL:** <https://discuss.aerospike.com/t/aerospike-chat/974>\
**Category:** Node.js Client\
**Created:** [February 20, 2015, 1:14pm UTC](https://discuss.aerospike.com/t/aerospike-chat/974 "2015-02-20T13:14:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Stejskal](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Daniel\_Stejskal](https://discuss.aerospike.com/u/Daniel_Stejskal)\
**Post date:** [February 20, 2015, 1:14pm UTC](https://discuss.aerospike.com/t/aerospike-chat/974/1 "2015-02-20T13:14:40Z")

</div>

Hello, i would like to create a online chat room(s) for our client. The structure is: namespace: chat set: [room id] key: [microtimestamp]

There is no problem with record creation, but i am not able to write proper query to get last 30 records inserted.

```
       var statement = {};
	
	if (last_id != null) {
		statement.filters = [aerospike.filter.range('created', last_id, 99999999999999)];
	}
	
	var results = [];
	
	var query = client.query('chat', objectId);
	var stream = query.execute();
	
	stream.on('data', function(result) {
		
		var id = result.meta.key;
		result = result.bins;
		result.id = id;
		
		results.push(result);
	});
	stream.on('error', function(error) {
		okCb();
	});
	stream.on('end', function(end) {
		okCb(results);
	});

```

Can you please help me? Thank you

---

<div class="post-metadata">

**Author:** ![iamontheinet](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@iamontheinet](https://discuss.aerospike.com/u/iamontheinet)\
**Post date:** [February 20, 2015, 7:17pm UTC](https://discuss.aerospike.com/t/aerospike-chat/974/2 "2015-02-20T19:17:09Z")

</div>

Hi Daniel,

I see that you’re filtering only if `last_id` is not null but `statement` is never passed to `client.query('chat', objectId);` — so the code as is will always return all records in `chat` \>\> `objectId` set.

Is that what you’re experiencing and referring to? If not, please share more info with regards to:

- Expected result vs actual result you’re seeing with your data set
- Secondary index(es) you’ve created
- If there are any errors being output in the console or log

Thanks!

Dash

---

<div class="post-metadata">

**Author:** ![Daniel\_Stejskal](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Daniel\_Stejskal](https://discuss.aerospike.com/u/Daniel_Stejskal)\
**Post date:** [February 23, 2015, 11:28am UTC](https://discuss.aerospike.com/t/aerospike-chat/974/3 "2015-02-23T11:28:31Z")

</div>

Thank you for your answer. Now i am passing the filter into statement. The problem is that i am unable to get records in ordered list. I use bin “created” (micro time stamp) as index (i am not sure how to use it properly) and as a key. I need last 30 records only.

---

<div class="post-metadata">

**Author:** ![iamontheinet](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@iamontheinet](https://discuss.aerospike.com/u/iamontheinet)\
**Post date:** [February 24, 2015, 4:37am UTC](https://discuss.aerospike.com/t/aerospike-chat/974/4 "2015-02-24T04:37:42Z")

</div>

Hi Daniel,

For ordered list, we’d recommend using Aerospike’s Large Ordered List. **IMP to note** : It is currently (as of version 1.0.30) **not** available in our Node.js client but we’re actively working on adding it. In the meantime, you can read more about it here - [https://www.aerospike.com/docs/guide/llist.html](https://www.aerospike.com/docs/guide/llist.html)

I hope this helps.
