Skip to content

Commit a506cc4

Browse files
committed
rename object key in index without changing it's position
1 parent c224bfe commit a506cc4

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/schema.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,11 +2037,9 @@ Schema.prototype.index = function(fields, options) {
20372037
}
20382038
for (const key in fields) {
20392039
if (this.aliases[key]) {
2040-
fields[this.aliases[key]] = fields[key];
2041-
delete fields[key];
2040+
fields = utils.renameObjKey(fields, key, this.aliases[key]);
20422041
}
20432042
}
2044-
20452043
for (const field of Object.keys(fields)) {
20462044
if (fields[field] === 'ascending' || fields[field] === 'asc') {
20472045
fields[field] = 1;

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ exports.renameObjKey = function (oldObj, oldKey, newKey) {
983983
}
984984
return acc;
985985
},
986-
{} as Record<string, unknown>
986+
{}
987987
);
988988
}
989989

0 commit comments

Comments
 (0)