Skip to content

Commit

Permalink
Merge pull request #257 from cabcookie:consider-activities-with-peopl…
Browse files Browse the repository at this point in the history
…e-mentioned

chore: add an index to NoteBlockPerson personId
  • Loading branch information
cabcookie authored Nov 28, 2024
2 parents 0a41cf0 + 3015418 commit a928b3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions amplify/data/activity-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ const activitySchema = {
person: a.belongsTo("Person", "personId"),
noteBlockId: a.id().required(),
noteBlock: a.belongsTo("NoteBlock", "noteBlockId"),
createdAt: a.datetime().required(),
})
.secondaryIndexes((index) => [
index("personId").sortKeys(["createdAt"]).queryField("listByPersonId"),
])
.authorization((allow) => [allow.owner()]),
NoteBlock: a
.model({
Expand Down
2 changes: 2 additions & 0 deletions api/helpers/people.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type Schema } from "@/amplify/data/resource";
import { newDateTimeString } from "@/helpers/functional";
import { generateClient } from "aws-amplify/api";
const client = generateClient<Schema>();

Expand All @@ -9,4 +10,5 @@ export const createMentionedPersonApi = (
client.models.NoteBlockPerson.create({
noteBlockId,
personId,
createdAt: newDateTimeString(),
});

0 comments on commit a928b3a

Please sign in to comment.