Understanding QuerySnapshot Values Returned by Cloud Firestore Library in JavaScript

Asked 1 years ago, Updated 1 years ago, 78 views

I would like to ask you about the return value in the Cloud Firestore library.Regarding the value returned when executing the code below, is this an instance?
For example, if I want to retrieve the 'testCollection' string, what should I specify?

Executed Code

const docsRefs=wait db.collection(dbColPath).get()
console.log(docsRefs)

Returned Value

QuerySnapshot{
  _query:CollectionReference {
    various
    },
    _queryOptions:QueryOptions{
      parentPath: ResourcePath,
      collectionId: 'testCollection',
      various
    },
    _serializer:Serializer {
      various
    },
    _allowUndefined: false
  },
  various
}

Add

Doesn't this mean that you can manipulate the above objects with something like repr() in python?

If it's an instance, I think I can access it as follows...

class Car {
  constructor(make,model){
    This.make=make
    This.model=model
    this.userGears=['P', 'N', 'R', 'D']
    this.userGear=this.userGears[0]
  }
  shift(gear){
    if (this.userGears.indexOf(gear)<0)
      US>throw new Error (`Incorrect gear specification: ${gear}')
    This.userGear=gear
  }
}

const car1 = new Car ("Tesla", "Model S")
console.log (car1)
console.log (car1.make)

// execution result

Car{
  make: 'Tesla',
  model: 'Model S',
  userGears: ['P', 'N', 'R', 'D',
  userGear: 'P'
}
Tesla

javascript node.js firebase google-api

2022-09-30 19:27

1 Answers

The content of the data is
docsRefs.data()
Run the function to retrieve it.


2022-09-30 19:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.