Skip to content

Commit 7582397

Browse files
chore: wip
1 parent ddf5bf1 commit 7582397

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

storage/framework/core/database/src/drivers/dynamodb.ts

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const userSchema = item({
4545
id: string().required(),
4646
name: string().required(),
4747
email: string().required(),
48-
job_title: string(),
48+
jobTitle: string().required(),
4949
password: string().required(),
5050
public_passkey: string(),
5151
stripe_id: string(),
@@ -60,7 +60,59 @@ const UserEntity: Entity = new Entity({
6060
schema: userSchema,
6161
computeKey: (keyInput: any) => ({
6262
pk: `USER#${keyInput.id}`,
63-
sk: `USER#${keyInput.id}`
63+
sk: `USER#${keyInput.id}`,
64+
gsi1pk: `USER#EMAIL`,
65+
gsi1sk: `USER#${keyInput.id}`,
66+
gsi2pk: `USER#NAME`,
67+
gsi2sk: `USER#${keyInput.id}`
68+
})
69+
})
70+
71+
// Team Entity
72+
const teamSchema = item({
73+
id: string().required(),
74+
name: string().required(),
75+
companyName: string().required(),
76+
email: string().required(),
77+
billingEmail: string().required(),
78+
status: string().required(),
79+
description: string().required(),
80+
path: string().required(),
81+
isPersonal: string().required(),
82+
created_at: string(),
83+
updated_at: string()
84+
})
85+
86+
const TeamEntity: Entity = new Entity({
87+
name: 'Team',
88+
table: AppTable,
89+
schema: teamSchema,
90+
computeKey: (keyInput: any) => ({
91+
pk: `TEAM#${keyInput.id}`,
92+
sk: `TEAM#${keyInput.id}`,
93+
gsi1pk: `TEAM#EMAIL`,
94+
gsi1sk: `TEAM#${keyInput.id}`
95+
})
96+
})
97+
98+
// SubscriberEmail Entity
99+
const subscriberEmailSchema = item({
100+
id: string().required(),
101+
email: string().required(),
102+
created_at: string(),
103+
updated_at: string(),
104+
deleted_at: string()
105+
})
106+
107+
const SubscriberEmailEntity: Entity = new Entity({
108+
name: 'SubscriberEmail',
109+
table: AppTable,
110+
schema: subscriberEmailSchema,
111+
computeKey: (keyInput: any) => ({
112+
pk: `SUBSCRIBER#${keyInput.id}`,
113+
sk: `SUBSCRIBER#${keyInput.id}`,
114+
gsi1pk: `SUBSCRIBER#EMAIL`,
115+
gsi1sk: `SUBSCRIBER#${keyInput.id}`
64116
})
65117
})
66118

@@ -105,6 +157,8 @@ const generateKeys = {
105157
export {
106158
AppTable,
107159
UserEntity,
160+
TeamEntity,
161+
SubscriberEmailEntity,
108162
PostEntity,
109163
generateKeys,
110164
}

0 commit comments

Comments
 (0)