In this lab, we refactored our last lab and created two additional functions, remove and update.
-
Refactored our:
getObject(<data-dir>, <table>, <id>, callback)method intodb.get(<data-dir>, <table>, <id>, callback). -
Created a
db.removefunction that returns true if the object is removed, and false if it is not removed.
Usage:
remove(table, id, callback)
-
Tested the remove function with both an object that does exist upon setup, and an object which does not exist.
-
Created an
db.updatefunction that returns the newly updated object, or throws an error if the object does not exist.
Usage:
update(table, object, callback)
-
Tested the remove function with both an object that does exist upon setup, and an object which does not exist.
-
Cleaned up and slighly refactored the code and published to npm!