From 4db6b471d30b08213ae637c65c847fc5db2023e7 Mon Sep 17 00:00:00 2001 From: Diana Barsan <35681649+dianabarsan@users.noreply.github.com> Date: Mon, 12 Aug 2024 00:29:03 +0300 Subject: [PATCH] fix(#9298): no padstart in couchdb views (#9307) Removes padStart from CouchDb views. This function was not available in the Javascript engine packaged with CouchDb v2, which ships in CHT v4.3.x and lower. Unfortunately, when the view code crashes, it triggers a warning in CouchDb and the document is just skipped, while the view index advances. This means that that document needs to be edited in order to appear as a view result, or the whole index needs to be rebuilt, after upgrading to CouchDb 3. #9298 --- ddocs/users-meta-db/users-meta/views/device_by_user/map.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ddocs/users-meta-db/users-meta/views/device_by_user/map.js b/ddocs/users-meta-db/users-meta/views/device_by_user/map.js index 3edc3071c69..32cf781fef6 100644 --- a/ddocs/users-meta-db/users-meta/views/device_by_user/map.js +++ b/ddocs/users-meta-db/users-meta/views/device_by_user/map.js @@ -9,7 +9,8 @@ function(doc) { doc.metadata.day ) { var pad = function (number) { - return number.toString().padStart(2, '0'); + var string = number.toString(); + return string.length === 2 ? string : '0' + string; }; emit([doc.metadata.user, doc.metadata.deviceId], {