From b9a062d92f50153fda7c8f5d8e0853c75c978df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Urbina?= Date: Thu, 28 Dec 2023 20:10:58 +0000 Subject: [PATCH 1/2] Update README for TTL Policy --- src/firestore/README.md | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/firestore/README.md b/src/firestore/README.md index 74e87ac9282..95ffd264b66 100644 --- a/src/firestore/README.md +++ b/src/firestore/README.md @@ -61,8 +61,6 @@ The schema for one object in the `fieldOverrides` array is as follows. Optional Note that Cloud Firestore document fields can only be indexed in one [mode](https://firebase.google.com/docs/firestore/query-data/index-overview#index_modes), thus a field object cannot contain both the `order` and `arrayConfig` properties. -For more information about time-to-live (TTL) policies review the [official documentation](https://cloud.google.com/firestore/docs/ttl). - ```javascript collectionGroup: string // Labeled "Collection ID" in the Firebase console fieldPath: string @@ -72,3 +70,41 @@ For more information about time-to-live (TTL) policies review the [official docu order?: string // One of "ASCENDING", "DESCENDING"; excludes arrayConfig property arrayConfig?: string // If this parameter used, must be "CONTAINS"; excludes order property ``` + +#### TTL Policy + +A TTL policy can be enabled or disabled using the `fieldOverrides` array as it follows: + +```javascript + // Optional, disable index single-field collection group indexes + fieldOverrides: [ + { + collectionGroup: "posts", + fieldPath: "ttlField", + ttl: "true", // Explicitly enable TTL on this Field. + // Disable indexing so empty the indexes array + indexes: [] + } + ] +``` + +To keep the default indexing in the field and enable a TTL policy: + +```javascript +{ + "fieldOverrides": [ + { + "collectionGroup": "yourCollectionGroup", + "fieldPath": "yourFieldPath", + "ttl": true, + "indexes": [ + { "order": "ASCENDING", "queryScope": "COLLECTION_GROUP" }, + { "order": "DESCENDING", "queryScope": "COLLECTION_GROUP" }, + { "arrayConfig": "CONTAINS", "queryScope": "COLLECTION_GROUP" } + ] + } + ] +} +``` + +For more information about time-to-live (TTL) policies review the [official documentation](https://cloud.google.com/firestore/docs/ttl). From bd84f67462d7ff8e427918f501a4ee46c1b26ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Urbina?= Date: Thu, 28 Dec 2023 20:19:37 +0000 Subject: [PATCH 2/2] Update README for TTL policy. --- src/firestore/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/firestore/README.md b/src/firestore/README.md index 95ffd264b66..21416f4b552 100644 --- a/src/firestore/README.md +++ b/src/firestore/README.md @@ -76,16 +76,16 @@ Note that Cloud Firestore document fields can only be indexed in one [mode](http A TTL policy can be enabled or disabled using the `fieldOverrides` array as it follows: ```javascript - // Optional, disable index single-field collection group indexes - fieldOverrides: [ - { - collectionGroup: "posts", - fieldPath: "ttlField", - ttl: "true", // Explicitly enable TTL on this Field. - // Disable indexing so empty the indexes array - indexes: [] - } - ] +// Optional, disable index single-field collection group indexes +fieldOverrides: [ + { + collectionGroup: "posts", + fieldPath: "ttlField", + ttl: "true", // Explicitly enable TTL on this Field. + // Disable indexing so empty the indexes array + indexes: [], + }, +]; ``` To keep the default indexing in the field and enable a TTL policy: