query with limit(5) returns more than 5 elements #50
I am testing how nanoSQL behaves and I found something that it is not what I am expecting, so I wanted to ask if I am wrong or there is a bug. I have done a codepen:
My idea was to check whether an observable was invoked when an inserted element affect the result query (in this case the "second page"):
nSQL().observable( ( ) =>
And then I run some simple code that inserts elements in the database.
So I run into these 2 issues:
The text was updated successfully, but these errors were encountered:
Oh, forgot about your other question...
The observable actually uses .on("change") internally, but there are way more options for debouncing and filtering the output, all the options available:
nSQL().observable( ( ) => nSQL("users").query('select').limit( 5 ).offset( 5 ).emit() ) .debounce(1000) // dont trigger more than every second .distinct() // only trigger if the previous record doesn't match the next record to trigger .filter(rows => rows.length > 10) // use a filter function to only emit changes based on provided fn. .map(rows => rows) // mutate the result .first() // only emit the first change .skip(10) // skip the first n elements .take(10) // only get the first n elements .subscribe( update ) ;
Obviously each function is optional.