Skip to content

Commit 86768c9

Browse files
committed
feat(shelter-supply): add quantity property
1 parent 8896fe5 commit 86768c9

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "shelter_supplies" ADD COLUMN "quantity" INTEGER;

prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ model ShelterSupply {
5858
shelterId String @map("shelter_id")
5959
supplyId String @map("supply_id")
6060
priority Int @default(value: 0)
61+
quantity Int?
6162
createdAt String @map("created_at") @db.VarChar(32)
6263
updatedAt String? @map("updated_at") @db.VarChar(32)
6364

src/shelter-supply/shelter-supply.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ export class ShelterSupplyService {
2727
}
2828

2929
async store(body: z.infer<typeof CreateShelterSupplySchema>) {
30-
const { shelterId, priority, supplyId } =
30+
const { shelterId, priority, supplyId, quantity } =
3131
CreateShelterSupplySchema.parse(body);
3232
await this.handleUpdateShelterSum(shelterId, 0, priority);
3333
await this.prismaService.shelterSupply.create({
3434
data: {
3535
shelterId,
3636
priority,
3737
supplyId,
38+
quantity,
3839
createdAt: new Date().toISOString(),
3940
},
4041
});

src/shelter-supply/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const ShelterSupplySchema = z.object({
1212
z.literal(SupplyPriority.Needing),
1313
z.literal(SupplyPriority.Urgent),
1414
]),
15+
quantity: z.number().gt(0).nullable().optional(),
1516
createdAt: z.string(),
1617
updatedAt: z.string().nullable().optional(),
1718
});
@@ -20,6 +21,7 @@ const CreateShelterSupplySchema = ShelterSupplySchema.pick({
2021
shelterId: true,
2122
supplyId: true,
2223
priority: true,
24+
quantity: true,
2325
});
2426

2527
const UpdateShelterSupplySchema = z.object({
@@ -31,6 +33,7 @@ const UpdateShelterSupplySchema = z.object({
3133
z.literal(SupplyPriority.Needing),
3234
z.literal(SupplyPriority.Urgent),
3335
]),
36+
quantity: z.number().nullable().optional(),
3437
shelterId: z.string(),
3538
supplyId: z.string(),
3639
})

0 commit comments

Comments
 (0)