Batch insert attributes
(batch *pgx.Batch, xid db.XID8, tenantID string, attributeCollection *database.AttributeCollection)
| 486 | |
| 487 | // Batch insert attributes |
| 488 | func (w *DataWriter) batchInsertAttributes(batch *pgx.Batch, xid db.XID8, tenantID string, attributeCollection *database.AttributeCollection) error { |
| 489 | aiter := attributeCollection.CreateAttributeIterator() |
| 490 | for aiter.HasNext() { |
| 491 | a := aiter.GetNext() |
| 492 | jsonBytes, err := protojson.Marshal(a.GetValue()) |
| 493 | if err != nil { |
| 494 | return err |
| 495 | } |
| 496 | jsonStr := string(jsonBytes) |
| 497 | batch.Queue( |
| 498 | "INSERT INTO attributes (entity_type, entity_id, attribute, value, created_tx_id, tenant_id) VALUES ($1, $2, $3, $4, $5, $6)", |
| 499 | a.GetEntity().GetType(), a.GetEntity().GetId(), a.GetAttribute(), jsonStr, xid, tenantID, |
| 500 | ) |
| 501 | } |
| 502 | return nil |
| 503 | } |
| 504 | |
| 505 | // Batch update attributes |
| 506 | func (w *DataWriter) batchUpdateAttributes(batch *pgx.Batch, xid db.XID8, tenantID string, deleteClauses []squirrel.Eq) error { |
no test coverage detected