pg icon indicating copy to clipboard operation
pg copied to clipboard

Recursive Update

Open BastienVigneron opened this issue 4 years ago • 2 comments

Hello,

Did you know if it there is a way to recursively update a nested struct ?

Exemple :

type A struct {
	Id   int
	Name string
	B    B
}

type B struct {
	Id  int
	Age int
	C   C
}

type C struct {
	Id      int
	Address string
}

// then update A,B,C in only one operation 
	a := A{
		Id:   1,
		Name: "test",
		B:    B{
			Id:  1,
			Age: 10,
			C:   C{
				Id:      1,
				Address: "test address",
			},
		},
	}
	
	err := db.Update(a)

BastienVigneron avatar Jun 15 '20 18:06 BastienVigneron

@bastien-solutions you might find https://github.com/eleanorhealth/milo to be useful for this.

fterrag avatar Mar 17 '21 21:03 fterrag

Thank you @fterrag !

BastienVigneron avatar Mar 18 '21 08:03 BastienVigneron