Add Timestamps to person model (#490)

This commit is contained in:
Shubham Palriwala
2023-07-06 13:56:53 +05:30
committed by GitHub
parent 33811f9349
commit 8585cb8c7c
4 changed files with 14 additions and 0 deletions

View File

@@ -12,11 +12,15 @@ type TransformPersonInput = {
name: string;
};
}[];
createdAt: Date;
updatedAt: Date;
};
export type TransformPersonOutput = {
id: string;
attributes: Record<string, string | number>;
createdAt: Date;
updatedAt: Date;
};
export const transformPrismaPerson = (person: TransformPersonInput | null): TransformPersonOutput | null => {
@@ -32,6 +36,8 @@ export const transformPrismaPerson = (person: TransformPersonInput | null): Tran
return {
id: person.id,
attributes: attributes,
createdAt: person.createdAt,
updatedAt: person.updatedAt
};
};
@@ -78,6 +84,8 @@ export const getPeople = cache(async (environmentId: string): Promise<TPerson[]>
},
select: {
id: true,
createdAt: true,
updatedAt: true,
attributes: {
select: {
value: true,

View File

@@ -19,6 +19,8 @@ const responseSelection = {
person: {
select: {
id: true,
createdAt: true,
updatedAt: true,
attributes: {
select: {
value: true,

View File

@@ -6,6 +6,8 @@ export type TPersonAttributes = z.infer<typeof ZPersonAttributes>;
export const ZPerson = z.object({
id: z.string().cuid2(),
attributes: ZPersonAttributes,
createdAt: z.date(),
updatedAt: z.date()
});
export type TPerson = z.infer<typeof ZPerson>;

View File

@@ -36,6 +36,8 @@ const ZResponse = z.object({
.object({
id: z.string().cuid2(),
attributes: z.record(z.union([z.string(), z.number()])),
createdAt: z.date(),
updatedAt: z.date(),
})
.nullable(),
personAttributes: ZResponsePersonAttributes,