deepkit / deepkit-framework

A new full-featured and high-performance TypeScript framework
https://deepkit.io/
MIT License
3.22k stars 123 forks source link

support nested fields in patchOne() with mongodb #402

Closed colorcube closed 1 year ago

colorcube commented 1 year ago

Example

class FullName {
    forename: string = '';
    surname: string = '';
}

class Something {
    name: FullName = new FullName();
}

database.query(Something)
    .filter({'name.surname': 'Meier'})
    .patchOne({'name.forename': 'Klaus'})

filter() works fine patchOne() doesn't

error TS2345: Argument of type '{ 'name.forename': string; }' is not assignable to parameter of type 'ChangesInterface<Something> | Partial<Something>'.
  Object literal may only specify known properties, and ''name.forename'' does not exist in type 'ChangesInterface<Something> | Partial<Something>'.

59         .patchOne({'name.forename': 'Klaus'});
marcj commented 1 year ago

Fixed in https://github.com/deepkit/deepkit-framework/commit/0cec35f590bb873f19841130a87b12aa93fecbce