storj/pkg/accounting/dbx/accounting.dbx
Bill Thorp b2a8a10b16
redo tally query (#742)
* redo tally query

* broken, sharing w/ Jen

* tally tests added, failiing

* fix txn issue in tally

* fix lint
2018-12-05 09:03:23 -05:00

52 lines
1.2 KiB
Plaintext

// dbx.v1 golang accounting.dbx .
// timestamps just allows us to save the last time/thing that happened
model timestamps (
key name
field name text
field value timestamp ( updatable )
)
create timestamps ( )
update timestamps ( where timestamps.name = ? )
read scalar (
select timestamps.value
where timestamps.name = ?
)
model aggregate (
key node_id
field node_id text
field start_time timestamp ( updatable )
field interval int64 ( updatable )
field created_at timestamp ( autoinsert )
field updated_at timestamp ( autoinsert, autoupdate )
)
create aggregate ( )
update aggregate ( where aggregate.node_id = ? )
delete aggregate ( where aggregate.node_id = ? )
read one (
select aggregate
where aggregate.node_id = ?
)
model granular (
key node_id
field node_id text
field start_time timestamp ( updatable )
field end_time timestamp ( updatable )
field data_total int64 ( updatable )
field created_at timestamp ( autoinsert )
field updated_at timestamp ( autoinsert, autoupdate )
)
create granular ( )
update granular ( where granular.node_id = ? )
delete granular ( where granular.node_id = ? )
read one (
select granular
where granular.node_id = ?
)