I try to create and returns a new Query instance that applies a field mask to the result and returns only the specified subset of fields.
When i use :
let query = firestore.collection('col').select('field1','field2','field3').get() ...
it's ok, the query returns all the collection documents with only the 3 specified fields.
In my context application, the specified fields list is on a configuration document. When i use :
let fieldsList = ['field1','field2','field3'];
let query = firestore.collection('col').select(fieldsList).get() ...
i have an error message "Argument at index 0 is not a valid FieldPath ..."
On the Google documentation , it is specified " You can specify a list of field paths to return "
So, i don't know how to pass a list of field paths to the query select method.
Many thanks for your help !!!
You are working on what is known as spread syntax
. To make it work, it need to add triple dots in front of fieldList
:
let query = firestore.collection('col').select(...fieldsList).get() ..
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.