Skip to content

Commit 96815ef

Browse files
authored
Merge pull request #71 from deso-protocol/begin-add-relations-to-types
Begin adding relations for types
2 parents aa7d0fd + 79dcee5 commit 96815ef

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

entries/access_group.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ type AccessGroupEntry struct {
1313
AccessGroupKeyName string `pg:",use_zero"`
1414
AccessGroupPublicKey string `bun:",nullzero"`
1515

16+
AccessGroupMembers []*PGAccessGroupMemberEntry `bun:"rel:has-many,join:access_group_owner_public_key=access_group_owner_public_key,join:access_group_key_name=access_group_key_name"`
17+
1618
ExtraData map[string]string `bun:"type:jsonb"`
17-
BadgerKey []byte `pg:",pk,use_zero"`
19+
BadgerKey []byte `bun:",pk" pg:",pk,use_zero"`
1820
}
1921

2022
type PGAccessGroupEntry struct {

entries/access_group_member.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ type AccessGroupMemberEntry struct {
1616

1717
EncryptedKey []byte `pg:",use_zero"`
1818

19+
AccessGroupMemberAccount *PGAccount `bun:"rel:belongs-to,join:access_group_member_public_key=public_key"`
20+
AccessGroupOwnerAccount *PGAccount `bun:"rel:belongs-to,join:access_group_owner_public_key=public_key"`
21+
AccessGroup *PGAccessGroupEntry `bun:"rel:belongs-to,join:access_group_owner_public_key=access_group_owner_public_key,join:access_group_key_name=access_group_key_name"`
22+
1923
ExtraData map[string]string `bun:"type:jsonb"`
20-
BadgerKey []byte `pg:",pk,use_zero"`
24+
BadgerKey []byte `bun:",pk" pg:",pk,use_zero"`
2125
}
2226

2327
type PGAccessGroupMemberEntry struct {

entries/account.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package entries
2+
3+
import "github.com/uptrace/bun"
4+
5+
type PGAccount struct {
6+
bun.BaseModel `bun:"table:account"`
7+
8+
Pkid string `bun:"pkid,pk"` // We make Pkid the primary key so that bun is happy.
9+
PublicKey string `bun:"public_key"`
10+
Username string `bun:"username"`
11+
Description string `bun:"description"`
12+
ProfilePic string `bun:"profile_pic"`
13+
CreatorBasisPoints uint64 `bun:"creator_basis_points"`
14+
CoinWatermarkNanos uint64 `bun:"coin_watermark_nanos"`
15+
MintingDisabled bool `bun:"minting_disabled"`
16+
DaoCoinMintingDisabled bool `bun:"dao_coin_minting_disabled"`
17+
// TODO: bun seems to have a limit to the length of the string it can store in a column name.
18+
//DaoCoinTransferRestrictionStatus string `bun:"dao_coin_transfer_restriction_status"`
19+
ExtraData map[string]interface{} `bun:"extra_data"`
20+
CoinPriceDeSoNanos uint64 `bun:"coin_price_deso_nanos"`
21+
DeSoLockedNanos uint64 `bun:"deso_locked_nanos"`
22+
CCCoinsInCirculationNanos uint64 `bun:"cc_coins_in_circulation_nanos"`
23+
//DAOCoinsInCirculationNanosHex uint64 `bun:"dao_coins_in_circulation_nanos_hex"`
24+
}

entries/user_association.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ type UserAssociationEntry struct {
1818
AssociationValue string `pg:",use_zero"`
1919
BlockHeight uint32 `bun:",nullzero"`
2020

21+
TransactorUser PGAccount `bun:"rel:belongs-to,join:transactor_pkid=pkid"`
22+
TargetUser PGAccount `bun:"rel:belongs-to,join:target_user_pkid=pkid"`
23+
AppUser PGAccount `bun:"rel:belongs-to,join:app_pkid=pkid"`
24+
2125
ExtraData map[string]string `bun:"type:jsonb"`
22-
BadgerKey []byte `pg:",pk,use_zero"`
26+
BadgerKey []byte `bun:",pk" pg:",pk,use_zero"`
2327
}
2428

2529
type PGUserAssociationEntry struct {

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func main() {
5555
// Setup profiler if enabled.
5656
if datadogProfiler {
5757
tracer.Start()
58-
err := profiler.Start(profiler.WithProfileTypes(profiler.CPUProfile, profiler.BlockProfile, profiler.MutexProfile, profiler.GoroutineProfile, profiler.HeapProfile))
58+
err = profiler.Start(profiler.WithProfileTypes(profiler.CPUProfile, profiler.BlockProfile, profiler.MutexProfile, profiler.GoroutineProfile, profiler.HeapProfile))
5959
if err != nil {
6060
glog.Fatal(err)
6161
}

0 commit comments

Comments
 (0)