googleapis / googleapis/google-cloud-node
Return the updated document values in the SDK response
- Lingua principale
- TypeScript
- Stelle
- 3.2k
- Fork
- 712
- Merge medio
- 2g 9h
- PR unite (30g)
- 104
Descrizione
**Is your feature request related to a problem? Please describe.**
Right now, if I am using the Node.js Firestore SDK, and I want to see what value was set when I specify `FieldValue.serverTimestamp()` as a field's value, I need to `DocumentReference.get()` the created or updated document after it has been created or updated. This is specified by the documentation for https://cloud.google.com/nodejs/docs/reference/firestore/latest/firestore/writeresult.
However, it seems like if I were to construct a REST API call using the request structure documented at https://firebase.google.com/docs/firestore/reference/rest/v1/projects.databases.documents/patch, I could use the DocumentMask to return fields with their updated/created values.
**Describe the solution you'd like**
I would like for Firestore SDK methods on `DocumentReference` to have another option property:
```
await firestore.collection('a').doc('b').update({ x: 'y' }, { returnFields: ['x'] });
```
**Describe alternatives you've considered**
I have considered using a `.get()` SDK method after using either the `.add()` or `.update()`. This seems like unnecessary added cost.
I have considered using a Node.js generated Date object as the field value but doing this would destroy the usefulness of the functionality that `FieldValue.serverTimestamp()` provides. The server timestamp is much more exact to when the document was created/updated.
**Additional context**
N/A
Thanks for your consideration!
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia leggendo i metodi update e add di Node.js Firestore DocumentReference e la documentazione di WriteResult. Confronta il loro comportamento attuale con il DocumentMask dell'endpoint REST patch e determina come returnFields dovrebbe esporre i valori aggiornati, inclusi i timestamp del server. Il lavoro è completato quando l'opzione proposta funziona senza un get successivo e la risposta dell'SDK contiene i campi richiesti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- google-cloud, node.js, typescript
- Ambito
- api, database
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100