add openmct domain object table and skeleton
This commit is contained in:
parent
c9b73ee006
commit
0a6a6bb66d
36
db.go
36
db.go
|
@ -314,40 +314,18 @@ func (tdb *TelemDb) GetValues(ctx context.Context, filter BusEventFilter,
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PacketDef is a database packet model
|
func (tdb *TelemDb) AddDocument(obj json.RawMessage) error {
|
||||||
type PacketDef struct {
|
return nil
|
||||||
Name string
|
|
||||||
Description string
|
|
||||||
Id int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FieldDef struct {
|
func (tdb *TelemDb) UpdateDocument(key string, obj json.RawMessage) error {
|
||||||
Name string
|
return nil
|
||||||
SubName string
|
|
||||||
Packet string
|
|
||||||
Type string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PacketNotFoundError is when a matching packet cannot be found.
|
func (tdb *TelemDb) GetDocument(key string) (json.RawMessage, error) {
|
||||||
type PacketNotFoundError string
|
|
||||||
|
|
||||||
func (e *PacketNotFoundError) Error() string {
|
|
||||||
return "packet not found: " + string(*e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPacketDefN retrieves a packet matching the given name, if it exists.
|
|
||||||
// returns PacketNotFoundError if a matching packet could not be found.
|
|
||||||
func (tdb *TelemDb) GetPacketDefN(name string) (*PacketDef, error) {
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPacketDefF retrieves the parent packet for a given field.
|
func (tdb *TelemDb) DeleteDocument(key string) error {
|
||||||
// This function cannot return PacketNotFoundError since we have SQL FKs enforcing.
|
return nil
|
||||||
func (tdb *TelemDb) GetPacketDefF(field FieldDef) (*PacketDef, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetFieldDefs returns the given fields for a given packet definition.
|
|
||||||
func (tdb *TelemDb) GetFieldDefs(pkt PacketDef) ([]FieldDef, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
2
migrations/7_domainobject_down.sql
Normal file
2
migrations/7_domainobject_down.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
DROP TABLE openmct_objects;
|
||||||
|
DROP INDEX openmct_key;
|
6
migrations/7_domainobject_up.sql
Normal file
6
migrations/7_domainobject_up.sql
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
CREATE TABLE openmct_objects (
|
||||||
|
data TEXT,
|
||||||
|
key TEXT GENERATED ALWAYS AS (json_extract(data, '$.identifier.key')) VIRTUAL UNIQUE NOT NULL
|
||||||
|
);
|
||||||
|
-- fast key-lookup
|
||||||
|
CREATE INDEX openmct_key on openmct_objects(key);
|
Loading…
Reference in a new issue