diff --git a/amplify/data/activity-schema.ts b/amplify/data/activity-schema.ts index d426de91f..3761a058c 100644 --- a/amplify/data/activity-schema.ts +++ b/amplify/data/activity-schema.ts @@ -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({ diff --git a/api/helpers/people.ts b/api/helpers/people.ts index e95d84c4c..e252d8c90 100644 --- a/api/helpers/people.ts +++ b/api/helpers/people.ts @@ -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(); @@ -9,4 +10,5 @@ export const createMentionedPersonApi = ( client.models.NoteBlockPerson.create({ noteBlockId, personId, + createdAt: newDateTimeString(), });