Is there a way to retrieve the name of a document stored within a collection using Firebase Firestore and Firebase Storage

When fetching data from the 'users' collection in Firebase Firestore and mapping the response, I have a function that converts the array of domains and filters out any domains that do not meet certain criteria. Here's an example:

Sample domain object:

{creationDate:1516798886902
displayName:"mohamedabo8414"
domain:"@mohamedabo8414"
followersCount:0
followingCount:0}

I am looking to retrieve the UID for this particular user. Can anyone suggest how I can achieve this?

Answer №1

If you're missing keys when using .valueChanges(), consider switching to .snapshotChanges() for the desired result. Check out the code snippet below:

this.afs.collection<User>(`users`).snapshotChanges().map(actions=>{
    return actions.map(b=>{
        const data = b.payload.doc.data();
        const id = b.payload.doc.id;
        return {uid:id,...data}
    })
}).map(domains => {
    return this.convertToArray(domains).filter(domain => {
        return domain;
    });
});

Answer №2

After reviewing your feedback

The unique identifier for the domain object is "VEtdoqabg4bkanB6Ky9CI3dvzOu1": { creationDate:1516798886902 displayName:"mohamedabo8414" domain:"@mohamedabo8414" followersCount:0 followingCount:0}

If you need to access the uid VEtdoqabg4bkanB6Ky9CI3dvzOu1, as per the guidelines outlined in the official documentation, utilizing domain.id() should retrieve the aforementioned uid in your scenario.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigating through a list using tabs and automatic scrolling to a specific index in React with Material UI's Scrollspy

If there was a vast array of items, each belonging to a specific category, const categories: string[] = [0, 1, 2, 3, 4, 5]; const items: {name: string, category: number}[] = [{name: "foo", category: 1}, {name: "bar", category: 1}, {name ...

The function signature '() => Element' is incompatible with the type 'string'

Greetings! I have a standard function that returns a span with a prop (if I'm not mistaken). In my TS code, I am encountering this error: Error image Below is the code from the file named qCard.tsx: import { QuestionAnswerTwoTone } from "@material- ...

Display a free Admob banner within an Ionic 3 application

I have integrated Admob's banner into my Ionic 3 app following the guidelines provided in the Ionic documentation at this link. Below is the code snippet I used for displaying the banner on the homepage: import { Component } from '@angular/core ...

Deleting and inserting an element in the Document Object Model

I am currently working on developing a framework and need to create a directive called cp-if. Unlike the existing cp-show directive, where I can simply change the visibility of an element to 'none' and then make it visible again, with the cp-if d ...

Setting the title of a document in Angular 5 using HTML escaped characters

It seems like a simple problem, but I can't seem to find an easy solution. Currently, I am using the Title service to add titles to my documents and everything is working fine. You can check out the documentation here: https://angular.io/guide/set-doc ...

The TypeScript command tsc -p ./ is causing errors in the typings modules

Whenever I try to execute the typescript command tsc -p ./, I encounter an error. This issue seems to be occurring with es6-shim and some other node packages. Below is my package.json: "scripts": { "vscode:prepublish": "tsc -p ./", "compile": "t ...

Caution: Npm Angular alert during package installation

I keep encountering npm warnings while attempting to install packages: $ npm install npm WARN @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee8d81839e87828b9cc38d8287aedfdec0dec0dc">[email protected]</a> ...

Troubleshooting: The issue of ngModel being undefined in Angular2 with the <input> element

I am currently working with Angular2 and a modified version of Semantic-UI that includes a calendar module. I am utilizing the `calendar` and `dropdown` functionalities: constructor() { setTimeout(() => { jQuery('.ui.dropdown').dr ...

Pulling the month name based on a specific year and week using Javascript

In my HTML form, there are two fields called Year and Week. When the user chooses a Year and Week from the dropdowns, I would like to show the corresponding Month Name for that specific year and week. Is there anyone who can assist me in retrieving the m ...

An error has occurred: The repository is not clear. Kindly commit or stash any modifications before proceeding with the update

I am looking to upgrade my Angular 6 project to Angular 8. First step is to execute npm install -g @angular/cli@latest (this code works fine). Next, run ng update @angular/cli @angular/core. However, I encountered the following error: The repository i ...

Using Typescript in the browser with Babel and Webpack: Step-by-Step Guide

I've been exploring the use of Typescript in my browser with a specific architecture: Typescript in browser architecture However, I'm facing an issue with the import/export functionality when running this command: tsc && babel build-ts -d lib && ...

Working with relative paths in React Native TypeScript using WebStorm

My variable color is located in the path app/theme. To set it up, I created a package.json file in app/package.json with the following content: { "name": "app" } Now, to import color in TypeScript files, I use the following syntax: import { color } fro ...

What is the technique for highlighting the exact data point on the XY am4chart when it is clicked?

I have been searching high and low for a solution to my problem but haven't had any luck. I am working with a traditional XY am4chart that has hundreds of data points in the line series. What I want is for the chart to display a vertical line (or some ...

What is the proper way to transmit JSON data to a node.js server using the fetch API in JavaScript

I am currently working with a node.js back-end server and Angular 10 on the front-end. I need to pass data from the front-end to the back-end using fetch. This is my front-end code: testmariadb($event: MouseEvent) { return fetch('/api/customQuery ...

In Typescript, you can easily group a string into sections that consist of digits like 345-67, along with text containing a

I have a string that looks like this: "[111-11] text here with digits 111, [222-22-22]; 333-33 text here" and I am trying to parse it so that I can extract the code [111-11], [222-22-22], [333-33] along with their respective text descriptions. The challeng ...

Error: The next.config.js file contains invalid options - The root value includes an unexpected property

I recently updated my next version from 10 to 12, and when I run the local development server, I encounter the following error in the terminal. As a result, the code fails to compile. How can I fix this issue? Invalid next.config.js options have been iden ...

Unexpected behavior with the ion-datetime time picker on an Android device

I am encountering challenges with a Date and Time entry feature in my Angular/Ionic application that involves date pickers. When I tap on the Time field, the time picker opens. Everything works perfectly in my browser - I can select a time, spin the value ...

How can I implement a dynamic form to display only when there are values available for the specified ID?

https://i.stack.imgur.com/imqYb.pngI am dealing with an object that is coming from the backend, containing template parameters such as "namespace,resources". In some cases, the template parameter value is "null". My goal is to display a form only when ther ...

Attempting to revert the imported module back to its initial/default mock configuration

When working on my test file, I utilize a folder named mocks which contains various exported functions. Most of the time, I rely on the mocks folder to perform all necessary tasks. However, there is one scenario where I need to adjust the return value to a ...

Angular 2 Typescript: Understanding the Structure of Member Properties and Constructors

I am currently exploring a project built with Ionic 2, Angular 2, and Typescript, and I find myself puzzled by the way member properties are being set. In the code snippet below, I noticed that Angular automatically injects dependencies into the construc ...