googleapis / googleapis/google-cloud-node

Return the updated document values in the SDK response

Offen
#7,478 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
api: firestore library: nodejs-firestore priority: p3 type: feature request
Vorherrschende Sprache
TypeScript
Sterne
3.2k
Forks
712
Ø Merge
2 T. 9 Std.
Gemergte PRs (30 T.)
104

Beschreibung

**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!

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, die Node.js Firestore DocumentReference-Methoden update und add sowie die Dokumentation zu WriteResult zu lesen. Vergleiche ihr aktuelles Verhalten mit der DocumentMask des REST-Patch-Endpunkts und bestimme, wie returnFields aktualisierte Werte einschließlich Serverzeitstempeln offenlegen sollte. Als erledigt gilt, dass die vorgeschlagene Option ohne einen anschließenden get funktioniert und die SDK-Antwort die angeforderten Felder enthält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
google-cloud, node.js, typescript
Bereich
api, database
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.