aaronpowell / db.js

db.js is a wrapper for IndexedDB to make it easier to work against
http://aaronpowell.github.com/db.js/
MIT License
818 stars 142 forks source link

Wrong Limit syntax ? #92

Closed brailateo closed 10 years ago

brailateo commented 10 years ago

Got latest db.js and https://es6-promises.s3.amazonaws.com/es6-promise-2.0.0.js , patched Promise with something like that:

if ( typeof Promise === "undefined" ) {
    ES6Promise.r();
}

In Firefox ( 32 , native Promise ) I get: TypeError: IDBS.query(...).desc is not a function Wrong syntax? An example in the main readme.md would be just perfect!

IDBS.query( 'owners', 'version' )
    .desc()
    .limit(1)
    .execute()
    .done( function ( rezQuery ) {
        console.log('rezQuery ',rezQuery);
    } );
brailateo commented 10 years ago

I had to patch db.js here ...

var desc = function () {
    direction = 'prev';
    return {
        keys: keys,
        execute: execute,
        filter: filter,
        distinct: distinct,
        modify: modify,
        limit: limit,
        map: map
    };
};

introducing limit in return object and call it like that

IDBS.query( 'owners', 'version' )
    .all()
    .desc()
    .limit(1)
    .execute()
    .then( function ( rezQuery ) {
        console.log('rezQuery ',rezQuery);
    } );

in order to make it work!

aaronpowell commented 10 years ago

send a PR and I'll get it merged

Date: Tue, 14 Oct 2014 05:58:26 -0700 From: notifications@github.com To: db.js@noreply.github.com Subject: Re: [db.js] Wrong Limit syntax ? (#92)

I had to patch db.js here ...

var desc = function () { direction = 'prev'; return { keys: keys, execute: execute, filter: filter, distinct: distinct, modify: modify, limit: limit, map: map }; };

introducing limit in return object and call it like that

IDBS.query( 'owners', 'version' ) .all() .desc() .limit(1) .execute() .then( function ( rezQuery ) { console.log('rezQuery ',rezQuery); } );

in order to make it work!

— Reply to this email directly or view it on GitHub. =

brailateo commented 10 years ago

Oups! :-( I'm an old-style-svn-guy, didn't even tried to know what's PR/git so ... just drop this line

   limit: limit,

after line 398 in current db.js source and everything is ok! "desc" function member does not propagate properly the "limit" function Thanks, Teo