Skip to main content
corrected spelling of 'current' in code example
Source Link

The only way I found practical is by having aggregate data be duplicated, one is original props, second is current, like

type UserProps { id: number name: string } type User { original: UserProps, current: UserProps } 

When working with the aggregate we change current:

user.currecntcurrent.name = "new_name" 

When saving to the database we just check what changed and generate the optimal sql query:

function save(user: User) { let query = orm.user.update().where(id, user.current.id) if (user.current.name != user.original.name) { query.update('name', user.current.name) } } save(user) 

The only way I found practical is by having aggregate data be duplicated, one is original props, second is current, like

type UserProps { id: number name: string } type User { original: UserProps, current: UserProps } 

When working with aggregate we change current:

user.currecnt.name = "new_name" 

When saving to database we just check what changed and generate optimal sql query:

function save(user: User) { let query = orm.user.update().where(id, user.current.id) if (user.current.name != user.original.name) { query.update('name', user.current.name) } } save(user) 

The only way I found practical is by having aggregate data be duplicated, one is original props, second is current, like

type UserProps { id: number name: string } type User { original: UserProps, current: UserProps } 

When working with the aggregate we change current:

user.current.name = "new_name" 

When saving to the database we just check what changed and generate the optimal sql query:

function save(user: User) { let query = orm.user.update().where(id, user.current.id) if (user.current.name != user.original.name) { query.update('name', user.current.name) } } save(user) 
Source Link
ZiiMakc
  • 101
  • 3

The only way I found practical is by having aggregate data be duplicated, one is original props, second is current, like

type UserProps { id: number name: string } type User { original: UserProps, current: UserProps } 

When working with aggregate we change current:

user.currecnt.name = "new_name" 

When saving to database we just check what changed and generate optimal sql query:

function save(user: User) { let query = orm.user.update().where(id, user.current.id) if (user.current.name != user.original.name) { query.update('name', user.current.name) } } save(user)