#save() with nested entity in mongoose

2 messages · Page 1 of 1 (latest)

warm rapids
#

Hello.

I have this entity

@Schema()
export class Link {
  @Prop()
  name: string;

  @Prop()
  destination: string;

  @Prop()
  userId: string;

  @Prop()
  deviceDestinations: DeviceDestinations;
}

And when I change something like link.deviceDestinations.foo and do link.save() it doesn't actually get saved.
I noticed that I have to force new reference by

link.deviceDestinations = new DeviceDestinations()

For mongoose to pick up changes.

Any way to track changes to values of nested entities?

dusty hare
#

@warm rapids - What are you doing with foo? What change is that? What do your entities look like?