treojs / treo

Consistent API to IndexedDB
http://treojs.com
MIT License
257 stars 18 forks source link

Promise fails in standalone #44

Closed osc2nuke closed 8 years ago

osc2nuke commented 8 years ago

Using your snippet code from the manual i tried:

var fn = console.log.bind(console); // use it as callback

// define db schema
var schema = treo.schema()
.version(1)
.addStore('books', { key: 'isbn' })
.addIndex('byTitle', 'title', { unique: true })
.addIndex('byAuthor', 'author')
.version(2)
.getStore('books')
.addIndex('byYear', 'year')
.version(3)
.addStore('magazines')
.addIndex('byPublisher', 'publisher')
.addIndex('byFrequency', 'frequency');
// open db
var db = treo('library', schema)
.use(treoWebsql())
.use(treoPromise());
db.version; // 3
// put some data in one transaction
var books = db.store('books');

function getItem(){ 

    Promise.all([
        books.get('123456'),
        books.get('234567'),
        books.get('345678'),
    ]).then(function(records) {
        console.log(records); // records.length == 3  Console says : [undefined, undefined, undefined]

        books.count().then(function(count) {
            console.log(count); // total count of records //Works!!!! says 3
        });
    });
    }
osc2nuke commented 8 years ago

This can be ignored. The issue was related to wrong coding. Sorry, but it cause of experimenting and enthousiastic.