var DummyDB = (function(){

var DummyDB = {};

var storage = [];

var count = 1;


DummyDB.get = function(id){

if(id){

id = (typeof id == 'string') ? Number(id):id;


for(var i in storage) if (storage[i].id == id){

return storage[i];

}

}

else{

return storage;

}

};


DummyDB.insert = function(data){

data.id = count++;

storage.push(data);

return data;

};


DummyDB.remove = function(id){

//변수 가공

id = (typeof id == 'string') ? Number(id) : id;


for(var i in storage) if (storage[i].id == id){

storage.splice(i, 1);


return true;

}


return false;

};


return DummyDB;

})();

'javascript' 카테고리의 다른 글

json stringify  (0) 2017.11.18
tableToExcel  (0) 2017.08.18
promise  (0) 2017.03.12
json data roop  (0) 2012.02.29
DOM  (0) 2012.02.17

+ Recent posts