从 Firebase 和 Java 中提取特定数据

Pulling specific data from Firebase and Java

我正在尝试从 Firebase 的列表中提取特定数据元素。如何将变量设置为特定元素的数据,这样我就可以将它用于其他功能?

  getProducts() {
    return this.angularfire.database.list('/products', {
      query: {
        orderByChild: 'name'
      }
    });
  }

this.loadingProvider.show();
// Get all products from database.
this.dataProvider.getProducts().subscribe((products) => {
  this.products = products;

  console.log (products);
  this.products.forEach((product) => {
    // Add observer for the owner of the product to detect changes.
    this.dataProvider.getUser(product.userId).subscribe((user) => {
      product.user = user;
    });

Screenshot of Data

根据我从评论中收集到的信息...如果我理解正确...

如果你想在产品数组中使用 asins 中的对象数组,你可以这样做:

asins: string[] = [];

并迭代您的产品并从那里提取 asins:

this.products.forEach(product => {
   this.asins.push(product.ASIN)
});

最后你得到一个包含你的 asins 的字符串数组:

["ASIN1", "ASIN2", "ASIN3"]