Skip to content

Instantly share code, notes, and snippets.

@colevandersWands
Forked from JakeDuke/App Object.js
Last active April 17, 2018 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save colevandersWands/1e06ae259f7f8c7eed5500e70d1713a7 to your computer and use it in GitHub Desktop.
Save colevandersWands/1e06ae259f7f8c7eed5500e70d1713a7 to your computer and use it in GitHub Desktop.
var app = {
db: {},
next_id: 0,
create: function(newThing) {
// this.db[this.next_id] = newThing;
// this.next_id ++;
if(newThing !== ''){
this.db[this.next_id] = newThing;
this.next_id ++;
console.log("THING WAS ADDED")
return 'THING WAS ADDED';
}else{
console.log("ERROR")
return 'new value was an empty string, nopes.';
}
},
read: function(ID) {
if(this.db[ID]){
return this.db[ID];
} else {
return 'NOT FOUND';
}
},
update: function(ID, new_value) {
var returner = '';
// make this work
return returner // all good, bad id, bad input or bad id & bad input
},
delete: function(ID) {
if(this.db[ID]){
this.db[ID] = undefined;
console.log('item WAS DELETED');
} else{
console.log('UNKNOWN ID');
}
}
};
function app_handler() {
// read user input from dom
var result = app.create(user_input);
// write result to dom
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment