Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can update key value when mutateInsert duplicate key into map #322

Open
gugulee opened this issue Aug 10, 2022 · 0 comments
Open

can update key value when mutateInsert duplicate key into map #322

gugulee opened this issue Aug 10, 2022 · 0 comments

Comments

@gugulee
Copy link

gugulee commented Aug 10, 2022

when insert a duplicate key into map, it will be ingored.

can update key value when insert a duplicate key into map?
this is useful when update logical_switch_port table external_ids column.
for example,

// lsp.ExternalIDs should be map[ key:value ]
mutations := model.Mutation{
	Field:   &lsp.ExternalIDs,
	Value:   map[string]string{"key": "value"},
	Mutator: ovsdb.MutateOperationInsert,
}

ops, err := c.ovnNbClient.Where(lsp).Mutate(lsp, mutations)
if err != nil {
	return err
}

if err := c.Transact("ls-set-external-ids", ops); err != nil {
	return err
}

// insert `key`  repeatedly, lsp.ExternalIDs should be map[ key:value1 ]
mutations := model.Mutation{
	Field:   &lsp.ExternalIDs,
	Value:   map[string]string{"key": "value1"},
	Mutator: ovsdb.MutateOperationInsert,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant