【发布时间】:2019-07-19 09:10:08
【问题描述】:
我无法从 firebase 获取正确的结果。
我的代码是
const rootRef = firebase.database().ref()
console.log(rootRef)
const allEmployees = rootRef.child('employees').orderByChild('name').startAt('J')
console.log("These are all employees which names start with a J" + allEmployees)
这是控制台中的结果
Reference {repo: Repo, path: Path, queryParams_: QueryParams,
orderByCalled_: false}
database: (...)
key: (...)
orderByCalled_: false
parent: (...)
path: Path {pieces_: Array(0), pieceNum_: 0}
queryParams_: QueryParams {limitSet_: false, startSet_: false,
startNameSet_: false, endSet_: false, endNameSet_: false, …}
ref: (...)
repo: Repo {repoInfo_: RepoInfo, app: FirebaseAppImpl, dataUpdateCount:
0, statsListener_: null, eventQueue_: EventQueue, …}
root: (...)
__proto__: Query
These are all employees which names start with a J https://xxxxxxxx .firebaseio.com/employees
我试图实现的是打印出符合条件的员工列表,即他们的名字以 J 开头。
我还尝试匹配员工所属的类别
rootRef.child('employees').orderByChild('categoryID').equalTo('608Av3zkDS0cg2Iu66b2')
console.log(allEmployees)
但这给出了相同的结果,即数据库的 url。
谁能帮帮我。我已经为此烦恼了好几个小时。
【问题讨论】:
标签: javascript firebase firebase-realtime-database vuejs2