feat: add platform-collection relationship in platform.FetchCollection()

This commit is contained in:
Alexander Navarro 2024-11-25 19:54:41 -03:00
parent 8af94161ab
commit c1684c8dea
7 changed files with 184 additions and 79 deletions

View file

@ -19,20 +19,11 @@ package synchronizator
// return nil
// }
type StandardRelationship interface {
// How to transform the struct into a collection. It needs to return the class,
// and a []byte representation of the metadata.
//
// - class: Is used for classification and query pourposes. It's recomended to provide a constante string to increase consistency.
// - metadata: Arbitrary data. This will be stored as a jsonb in the database
//
ToRelationship() (string, []byte, error)
GetClass() string
GetNodes() (int64, int64)
GetMetadata() []byte
// How to transform a relationship into the struct. This method should modify the
// struct directly as it receives a pointer.
//
// - class: Is used for classification and query pourposes.
// - metadata: Arbitrary data. This is stored as a jsonb in the database
FromRelationship(string, []byte) error
SetConnection(*DB)
}
// A relationship in the database.
@ -42,5 +33,21 @@ type Relationship struct {
_class string // The class of the node, should not be modified to avoid inconsistencies.
From int64 // From what node this relation comes from
To int64 // To what node this relation goes to
Metadata []byte // Arbitrary data. This is stored as a jsonb in the database
metadata []byte // Arbitrary data. This is stored as a jsonb in the database
}
func (relation *Relationship) GetClass() string {
return relation._class
}
func (relation *Relationship) GetMetadata() []byte {
return relation.metadata
}
func (relation *Relationship) GetNodes() (int64, int64) {
return relation.From, relation.To
}
func (relation *Relationship) SetConnection(db *DB) {
relation._conn = db
}