fix: merge option with filter target key (#5558)

This commit is contained in:
ChengLei Shao 2024-10-31 21:41:10 +08:00 committed by GitHub
parent 809ae5c011
commit e818195dd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -653,9 +653,14 @@ export class Collection<
updateOptions(options: CollectionOptions, mergeOptions?: any) {
let newOptions = lodash.cloneDeep(options);
newOptions = merge(this.options, newOptions, mergeOptions);
this.context.database.emit('beforeUpdateCollection', this, newOptions);
this.options = newOptions;
if (options.filterTargetKey) {
newOptions.filterTargetKey = options.filterTargetKey;
}
this.context.database.emit('beforeUpdateCollection', this, newOptions);
this.options = newOptions;
this.setFields(options.fields, false);
if (options.repository) {
this.setRepository(options.repository);