Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
How do i grab the document name from firebase

I have using this component to push data out, however i can not grab the document name i.e. "sampleCloudFunction" under CloudFunctionMonitor(please see picture) from the database and display it

enter image description here

docRef.id does not work, i am not looking for the ID but the actual name of the sub document?

            <Card.Content>
              <Card.Header>{this.props.cloudFunction.docRef.id}</Card.Header>
              <Card.Description>{}</Card.Description>
            </Card.Content>

Full code index.js:

import "../../App";
import "semantic-ui-css/semantic.min.css";
import { Icon, Card, Button } from "semantic-ui-react";
import "semantic-ui-css/semantic.min.css";
import React, { Component } from "react";
import "semantic-ui-css/semantic.min.css";

export default class Cards extends Component {
  render() {
    return (
      <Card color="green">
        <Card.Content>
          <Card.Header>{this.props.cloudFunction.docRef.id}</Card.Header>
          <Card.Description>{}</Card.Description>
        </Card.Content>
        <Card.Content extra>
          <Icon name="cog" /> Records: {this.props.cloudFunction.lastRunLoad}
          <br />
          <Icon name="cog" />
          {this.props.cloudFunction.lastRunMessage}
          <br />
          <Icon name="clock" /> Last Run:{" "}
          {this.props.cloudFunction.lastRunTime.toDate().toString()}
          <br />
          <Icon name="angle double down" />
          Schedule: {this.props.cloudFunction.schedule}
        </Card.Content>
        <Card.Content extra>
          <div className="ui two buttons">
            <Button basic color="green">
              Cloud Function
            </Button>
          </div>
        </Card.Content>
      </Card>
    );
  }
}

Firestore Query

useEffect(() => {
  const unsubscribe = FirestoreService.getCloudFunctionItems(
    (querySnapshot) => {
      const updatedCloundFunctions = querySnapshot.docs.map(
        (docSnapshot) => ({
          guid: uuidV4(),
          ...docSnapshot.data(),
        })
      );
      console.log(updatedCloundFunctions);
      setCloudFunctions(updatedCloundFunctions);
    },
    (error) => setError("list-item-get-fail")
  );
  return unsubscribe;
}, []);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The document data does not contain it's ID. You'll have to explicitly add it as shown below:

const updatedCloundFunctions = querySnapshot.docs.map((docSnapshot) => ({
    guid: uuidV4(),
    // Add Document ID
    id: docSnapshot.id
    ...docSnapshot.data(),
  })
);

Then you can access it by this.props.cloudFunction.id

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!