I need to get array of objects of sources from firebase grouped by category. Firebase structure is: enter image description here
Every authenticated user have its own array of sources. Security rules for db is: enter image description here Every source have array of articles and have category. I use vuefire to bind to firebase-database. I have written this, but I don't know what I should do next to get all sources grouped by category.
var sources=[];
var db=firebase.database();
var id=auth.user().uid;
var userDb=db.ref(id);
Maybe you can imagine how to retrieve your data from firebase database if I give you this example:
function getData(data) {
var items = data.val();
console.log(items, 'myItem') //here is your items that you need
}
function errData(err) {
console.log('error:', err)
}
const id = firebase.auth().currentUser.uid;
const result = firebase.database().ref(id);
result.on('value', getData, errData)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.