Created
June 16, 2023 15:26
-
-
Save thobson/841ca6598a390eb1bd3644ac916eb435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity } from "electrodb"; | |
import { client, table } from "../client"; | |
export const UserEntity = new Entity( | |
{ | |
model: { | |
version: "1", | |
entity: "user", | |
service: "default", | |
}, | |
attributes: { | |
userId: { | |
type: "string", | |
required: true, | |
readOnly: true, | |
}, | |
firstName: { | |
type: "string", | |
required: true | |
} | |
}, | |
indexes: { | |
primary: { | |
collection: "overview", | |
pk: { | |
field: "pk", | |
composite: ["userId"], | |
}, | |
sk: { | |
field: "sk", | |
composite: [], | |
}, | |
} | |
} | |
}, | |
{ client, table } | |
); | |
export const ItemEntity = new Entity( | |
{ | |
model: { | |
version: "1", | |
entity: "user", | |
service: "default", | |
}, | |
attributes: { | |
userId: { | |
type: "string", | |
required: true, | |
readOnly: true, | |
}, | |
itemId: { | |
type: "string", | |
required: true, | |
readOnly: true, | |
}, | |
itemName: { | |
type: "string", | |
required: true | |
} | |
}, | |
indexes: { | |
primary: { | |
collection: "overview", | |
pk: { | |
field: "pk", | |
composite: ["userId"], | |
}, | |
sk: { | |
field: "sk", | |
composite: ["itemId"], | |
}, | |
} | |
} | |
}, | |
{ client, table } | |
); | |
export const ImageEntity = new Entity( | |
{ | |
model: { | |
version: "1", | |
entity: "user", | |
service: "default", | |
}, | |
attributes: { | |
userId: { | |
type: "string", | |
required: true, | |
readOnly: true, | |
}, | |
imageId: { | |
type: "string", | |
required: true, | |
readOnly: true, | |
}, | |
key: { | |
type: "string", | |
required: true | |
} | |
}, | |
indexes: { | |
primary: { | |
collection: "overview", | |
pk: { | |
field: "pk", | |
composite: ["userId"], | |
}, | |
sk: { | |
field: "sk", | |
composite: ["imageId"], | |
}, | |
} | |
} | |
}, | |
{ client, table } | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment