googleapis / googleapis/google-cloud-node

[FR] Add support for minimum and maximum field transforms

Open
#7,479 1 comment 3 reactions 0 assignees View on GitHub
api: firestore library: nodejs-firestore priority: p3 type: feature request
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

**Is your feature request related to a problem? Please describe.**

The _minimum_ and _maximum_ field transforms (which are available in the [REST API](https://firebase.google.com/docs/firestore/reference/rest/v1/Write#fieldtransform)) have not been implemented in the Firestore Node SDK

**Describe the solution you'd like**

I imagine the API for this would look very much like [`FieldValue.increment(...)`](https://firebase.google.com/docs/firestore/manage-data/add-data#increment_a_numeric_value), and would look something like:

```
// ...
const washingtonRef = db.collection('cities').doc('DC');

// Atomically set the value of population to the minimum of 50 or it's existing value
const res = await washingtonRef.update({
population: FieldValue.minimum(50)
});
```

**Describe alternatives you've considered**
n/a

**Additional context**
n/a

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.