Created
November 5, 2019 12:27
-
-
Save anil826/748cb1952ccdea30483fc77f587da145 to your computer and use it in GitHub Desktop.
DFG server offline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for browsers := get local db data and write on a file as a backup and download that on the devise | |
var db = Lawnchair( { name:'QFlocalStorage', adapter: localStorage.getItem("f_db_adapter") }, function( store ) { | |
}); | |
var collection_keys = []; | |
//Get all the entries id from local db | |
db.keys(function(keys) { | |
//Collect ids | |
collection_keys = _.filter(keys, function(key) { | |
return (new RegExp('forms-')).test(key); | |
}); | |
alert("Total form entries in db - "+ collection_keys.length ); | |
//Retrive the number of unsent entries | |
db.get(collection_keys, function(records) { | |
console.log(records) | |
var draft_entries = _.filter(records, function(entry) { | |
if ( entry && entry.value && JSON.parse(entry.value).draft ) { | |
var current_entry = JSON.parse(entry.value) | |
current_entry.dirty = true | |
current_entry.draft = false; | |
db.remove(entry.key,function(){ | |
}) | |
db.save({key: entry.key, value :JSON.stringify(current_entry)},function(result){ | |
console.log(result) | |
$(".refresh_btn").trigger("click") | |
}) | |
return entry; | |
} | |
}) | |
// alert("Total unsent from entries in DB - " + ( draft_entries.length ) ); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment