Created
October 10, 2012 14:26
-
-
Save JPalounek/3865969 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var DBService = function () {}; | |
DBService.prototype.insert = function (database, table, data) { | |
var tableData = this.select(database, table); | |
if(tableData != null) { | |
for(var id in tableData) {} | |
var lastId = parseInt(id) + 1; | |
} else { | |
tableData = {}; | |
var lastId = 1; | |
} | |
tableData[lastId] = data; | |
localStorage.setItem(database + '-' + table, JSON.stringify(tableData)); | |
} | |
DBService.prototype.select = function (database, table, query) { | |
var data = localStorage.getItem(database + '-' + table); | |
if(data == null) { | |
return null; | |
} else { | |
return JSON.parse(data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment