paldepind / synceddb

Makes it easy to write offline-first applications with realtime syncing and server side persistence.
MIT License
404 stars 34 forks source link

property 'put' of undefined #12

Closed MaartenProvo closed 8 years ago

MaartenProvo commented 8 years ago

Perhaps a stupid question, I get an error can not read property 'put' of undefined. But I can't find how to fix it, searched in the example files, but no clues there.

Anamnese - Pc v4.html.txt DB-Ambu-4.js.txt

piglovesyou commented 8 years ago

syncedDB.open().then() doesn't return db. So I guess this will work.

var db = syncedDB.open({
    name: 'Ambu-DB',
    // ...
});
db.then(function() {
    addPatients();
}).catch(function(err) {
    // ...
});

Or, because the argument of a function passed to SDBDatabase#then() is {db: db, e: e}, I think you can use that too.

piglovesyou commented 8 years ago

@MaartenProvo Tell me if you still have the problem even after the above answer.