Javascript database module for Indexeddb, Web SQL and localStorage storage mechanisms supporting version migration, advanced query, SQL and transaction.
Apache License 2.0
503
stars
41
forks
source link
deferred.promise not working after YDN include #109
Hi i am facing a problem in my app after including YDN for encryption-
1) I have included ydn lib in index.html page body section (tried adding in head also). I have other controllers also included in index.html (before as well as after YDN lib), as following-
2) storageservice.js is using ydn.db.Storage() as following -
function storageservice($q,avatarstorage, contactstorage, profilestorage, groupstorage,
archivestorage, notificationstorage) {
function open() {
var deferred = $q.defer();
var options = {
Encryption: {
encryptKey: false, // optional encrypt primary key
secrets: [{
name: 'aaaa',
key: 'aYHF6vfuGHpfWS*eRLrPQxZjS�~�?5c6HjCscqDqRtZasp�JWSMGaW'
}]
}
};
var schema = {
stores:[{
name:'profile',
encrypted: true
},{
name:'contacts',
encrypted: true
}]
};
var db = new ydn.db.Storage('nowconferdb', schema, options);
db.onReady(function() {
console.log('DB is initialized');
contactstorage.setDB(db); // prints logs in their corresponding setters
profilestorage.setDB(db);
console.log('After setup DB in storage services'); // prints well
deferred.resolve(true);
return deferred.promise;
});
db.addEventListener('fail', function (event) {
console.log("Failed in DB Setup");
var err = event.getError();
if (err.name == 'versionchange') {
console.log('The application is updated, please refresh to upgrade.');
contactstorage.setup(db);
profilestorage.setup(db);
} else {
console.log('connection failed with ' + err.name + ' by ' + err.message);
}
db = null; // no operation can be placed to the database instance
deferred.reject(false);
return deferred.promise;
});
}
return {
open: open
};
}
3) This storageservice is getting injected in my core resolver.js file to call the service and open DB.
storageservice.open().then(function(result) {
console.log('post initializing storageservice,result:'+result); // control doesn't return here,this log is not coming
}
Can anybody guide what is the problem in that,gone through normal promises but unable to find anything in this particular case.
Thanks a lot !!
Hi i am facing a problem in my app after including YDN for encryption-
1) I have included ydn lib in index.html page body section (tried adding in head also). I have other controllers also included in index.html (before as well as after YDN lib), as following-
<script src="/src/client/app/core/storage/settings.storage.js"></script><script type="text/javascript" src="./assets/ydnCoreCryptQryDev.js"></script><script src="/src/client/app/core/storageservice.js"></script>
2) storageservice.js is using ydn.db.Storage() as following -
function storageservice($q,avatarstorage, contactstorage, profilestorage, groupstorage, archivestorage, notificationstorage) {
3) This storageservice is getting injected in my core resolver.js file to call the service and open DB. storageservice.open().then(function(result) { console.log('post initializing storageservice,result:'+result); // control doesn't return here,this log is not coming }
Can anybody guide what is the problem in that,gone through normal promises but unable to find anything in this particular case. Thanks a lot !!