Given the data structure below in firebase, i want to run a query to retrieve the blog \'efg\'. I don\'t know the user id at this point.
{Users :
\"123
Given your current data structure you can retrieve the User that contains the blog post you are looking for.
const db = firebase.database()
const usersRef = db.ref('users')
const query = usersRef.orderByChild('blogs/efg').limitToLast(1)
query.once('value').then((ss) => {
console.log(ss.val()) //=> { '7654321': { blogs: {...}}}
})
You need to use limitToLast
since Objects are sorted last when using orderByChild
docs.