Skip to content

Commit

Permalink
fix(#9298): no padstart in couchdb views (#9307)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dianabarsan authored and sugat009 committed Aug 12, 2024
1 parent 02fe538 commit 4db6b47
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ddocs/users-meta-db/users-meta/views/device_by_user/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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], {
Expand Down

0 comments on commit 4db6b47

Please sign in to comment.