Skip to content

Commit

Permalink
Fix: TypeError: Cannot use 'in' operator to search for 'updatedAt' in…
Browse files Browse the repository at this point in the history
… undefined (#2113)

* Fix: TypeError: Cannot use 'in' operator to search for 'updatedAt' in undefined

Revert: Remove 'updateAt' property in leancloud update. (#2108)

* chore: use for...in replace hasOwnProperty

---------

Co-authored-by: Austin Lee <[email protected]>
  • Loading branch information
Mejituu and lizheming authored Oct 10, 2023
1 parent 616499a commit da7e95f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/server/src/service/storage/leancloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,16 @@ module.exports = class extends Base {
ret.map(async (item) => {
const _oldStatus = item.get('status');

var newData
if (think.isFunction(data)) {
newData = data(item.toJSON())
}
if ('updatedAt' in newData) {
delete newData.updatedAt
}
item.set(newData)
var updateData = typeof data === 'function' ? data(item.toJSON()) : data;

const REVERSED_KEYS = ['createdAt', 'updatedAt'];
for (const k in updateData) {
if (REVERSED_KEYS.includes(k)) {
continue;
}
instance.set(k, updateData[k]);
}

const _newStatus = item.get('status');

if (_newStatus && _oldStatus !== _newStatus) {
Expand Down

1 comment on commit da7e95f

@Mejituu
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instance.set(k, updateData[k]);
在这里应该是
item.set(k, updateData[k]);

Please sign in to comment.