diff options
Diffstat (limited to 'sklad/db.go')
-rw-r--r-- | sklad/db.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sklad/db.go b/sklad/db.go index 3420c23..300c1bd 100644 --- a/sklad/db.go +++ b/sklad/db.go @@ -13,6 +13,8 @@ type Series struct { Description string // what kind of containers this is for } +type ContainerId string + type Container struct { Series string // PK: what series does this belong to Number uint // PK: order within the series @@ -20,12 +22,15 @@ type Container struct { Description string // description and/or contents of this container } -type ContainerId string - func (c *Container) Id() ContainerId { return ContainerId(fmt.Sprintf("%s%s%d", db.Prefix, c.Series, c.Number)) } +func (c *Container) Children() []*Container { + // TODO: Sort this by Id, or maybe even return a map[string]*Container. + return indexChildren[c.Id()] +} + type Database struct { Password string // password for web users Prefix string // prefix for all container IDs |