Created
December 21, 2017 12:56
-
-
Save istar0me/69c7086be0bf7aebda3cc85dd61a21bb to your computer and use it in GitHub Desktop.
This file contains 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
async function findParent(name) { | |
let parentName | |
await dbRef.orderByChild("name").equalTo(name).once("value", snap => { // 到 Firebase 抓取資料 | |
let i = 0 | |
while (1) { | |
if (snap.val()[i] != null) { | |
console.log(snap.val()) | |
parentName = snap.val()[i].parent // 抓到父/母名字,並儲存到 parentName 變數 | |
break | |
} | |
i++ | |
} | |
}) | |
console.log(`parentName : ${parentName}`) // 印出"D2廣跋" | |
return parentName | |
} | |
console.log(findParent("E1時壽")) // 印出"Promise {<pending>}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment