Last active
October 26, 2015 02:30
-
-
Save vehas/067d982612fb0be3a1bb 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
/** | |
* query movie main character form movie name | |
* @constructor | |
* @param {string} name | |
* @param {function} success(characterArray) - success callback funtion return all record character | |
* @param {function} err(string) - error callback funtion return error string | |
*/ | |
function queryDB(name,success,err){ | |
var intern= { | |
name : "intern", | |
character :[ | |
{ name : "Ben" ,actor: "Robert De Niro", age:"70"}, | |
{ name : "Jules" ,actor: "Anne Hathaway", age:"22"}, | |
{ name : "Paige" ,actor: "JoJo Kushner", age:"5"}, | |
]}; | |
var martian={ | |
name : "martian", | |
character : [ { name : "Matt Damon" ,actor: "Mark Watney", age:"32"} ] | |
}; | |
var db = [intern, martian]; | |
for(var idx in db) if(db[idx].name ===name){ | |
setTimeout(function success() { | |
success(db[idx]); | |
}, 3000 ); | |
return; | |
} | |
setTimeout(function err() { | |
err("movie not found"); | |
}, 3000 ); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment