I’m trying to add a feature to the UpdateAnnotation
api, whereby I can convert an annotation to a region. It looks like this may already be an intended feature, given:
if cmd.IsRegion {
itemRight := item
itemRight.RegionId = item.Id
itemRight.Epoch = cmd.TimeEnd / 1000
// We don't know id of region right event, so set it to 0 and find then using query like
// ... WHERE region_id = <item.RegionId> AND id != <item.RegionId> ...
itemRight.Id = 0
if err := repo.Update(&itemRight); err != nil {
return Error(500, "Failed to update annotation for region end time", err)
}
}
The issue however is that if you don’t pass in all of the expected values, the API will null them out or set them as 0
. To fix this, I’d like to pull the expected fields from the Annotations
table using:
query := &annotations.ItemQuery{
OrgId: c.OrgId,
AnnotationId: annotationID,
}
items, err := repo.Find(query)
For some reason though, this never sets the fields appropriately on query
– query.annotationId
is always 0. I’m not sure why. Any help is appreciated.