MCPcopy Create free account
hub / github.com/Permify/permify / batchInsertAttributes

Method batchInsertAttributes

internal/storage/postgres/data_writer.go:488–503  ·  view source on GitHub ↗

Batch insert attributes

(batch *pgx.Batch, xid db.XID8, tenantID string, attributeCollection *database.AttributeCollection)

Source from the content-addressed store, hash-verified

486
487// Batch insert attributes
488func (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
506func (w *DataWriter) batchUpdateAttributes(batch *pgx.Batch, xid db.XID8, tenantID string, deleteClauses []squirrel.Eq) error {

Callers 2

writeMethod · 0.95
runOperationMethod · 0.95

Implementers 6

dataClientpkg/pb/base/v1/service_grpc.pb.go
UnimplementedDataServerpkg/pb/base/v1/service_grpc.pb.go
NoopDataWriterinternal/storage/storage.go
DataWriterinternal/storage/postgres/data_writer.
DataWriterinternal/storage/memory/data_writer.go
DataServerinternal/servers/data_server.go

Calls 8

GetTypeMethod · 0.65
HasNextMethod · 0.45
GetNextMethod · 0.45
GetValueMethod · 0.45
GetEntityMethod · 0.45
GetIdMethod · 0.45
GetAttributeMethod · 0.45

Tested by

no test coverage detected