Thomas Ankcorn
04/14/2022, 8:46 PMthdxr
04/14/2022, 8:47 PMThomas Ankcorn
04/14/2022, 8:47 PMThomas Ankcorn
04/14/2022, 8:48 PMthdxr
04/14/2022, 8:49 PMthdxr
04/14/2022, 8:49 PMThomas Ankcorn
04/14/2022, 8:50 PMthdxr
04/14/2022, 8:50 PMconst table = new Table(ctx.stack, "table", {
fields: {
pk: "string",
sk: "string",
gsi1pk: "string",
gsi1sk: "string",
gsi2pk: "string",
gsi2sk: "string",
},
primaryIndex: {
partitionKey: "pk",
sortKey: "sk",
},
globalIndexes: {
gsi1: {
partitionKey: "gsi1pk",
sortKey: "gsi1sk",
},
gsi2: {
partitionKey: "gsi2pk",
sortKey: "gsi2sk",
},
},
})
thdxr
04/14/2022, 8:50 PMThomas Ankcorn
04/14/2022, 9:04 PMconst table = new MagicTable(ctx.stack, "table", {
entities: [
{ name: 'users', values: { name: 'key', email: 'string' }}
{ name: 'posts', values: { slug: 'key', title: 'string', ..., user: MagicTable.relates_to('users') }
]
})
For some single table patterns you can kinda get away some predefined logic.
posts.find({ where: { user: 'thdxr' } }).then(results => {....})
Thomas Ankcorn
04/14/2022, 9:04 PMthdxr
04/14/2022, 9:04 PMname
email
etc in stacks codethdxr
04/14/2022, 9:04 PMthdxr
04/14/2022, 9:05 PMcodgen()
function which I call at the endThomas Ankcorn
04/14/2022, 9:05 PMthdxr
04/14/2022, 9:06 PMThomas Ankcorn
04/14/2022, 9:06 PMThomas Ankcorn
04/14/2022, 9:14 PMGeoffrey Dagley
05/19/2022, 7:38 PMthdxr
05/19/2022, 7:39 PMthdxr
05/19/2022, 7:39 PM