2

I'm using Jaydata JSLQ and Jaydata provider for IndexedDB, what I want to do is to get "top n" records. What I've done is first get the records in descending order then take the n max records from it, It looks like there is a bug or something with the provider, because what I get with descending order is right but the take function doesn't return top records from ordered list, it gets top records from ascending records!!. I've also tried "first" function and it didn't work either!. Below is how my code looks like:

offlinedb.TodoItems.orderByDescending('it.Id').take(2).toArray(function(items){    
        alert(item.Name);    
});

I'd be so thankful if anyone could help me on this.

Mohsen Asfia
  • 235
  • 1
  • 3
  • 12
  • Hello Mohsen! Your assumption is correct, I was able to reproduce the issue and it is a bug. Thank you for reporing it, I created an issue at Github: https://github.com/jaydata/jaydata/issues/81 . I will update this SO thread with the fix or the workaround. – Robesz Feb 04 '13 at 12:24

1 Answers1

1

The bug has been fixed in InMemoryProvider.js and will be released in JayData 1.3. You can make a new InMemoryProvider.js using the development branch or you can download this file from 1.3-pre: http://include.jaydata.org/1.3pre/jaydataproviders/InMemoryProvider.js

If this fix doesn't solve the problem, please re-open the issue - https://github.com/jaydata/jaydata/issues/81

Robesz
  • 1,646
  • 11
  • 13