From 03a51120360fdb9f6712536d0e62b020136cefec Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Tue, 6 Dec 2022 21:44:53 -0800 Subject: [PATCH] Fix updated_at field in api --- src/api/services/files.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/api/services/files.zig b/src/api/services/files.zig index 6f9c08c..21ac8e8 100644 --- a/src/api/services/files.zig +++ b/src/api/services/files.zig @@ -92,9 +92,9 @@ pub fn update(db: anytype, id: Uuid, meta: PartialMeta, alloc: std.mem.Allocator if (builder.set_statements_appended == 0) return error.NoChange; - try builder.andWhere("id = $1"); + try builder.set("updated_at", "$6"); - std.log.debug("{any}", .{meta}); + try builder.andWhere("id = $1"); try db.exec(try builder.terminate(), .{ id, @@ -102,6 +102,7 @@ pub fn update(db: anytype, id: Uuid, meta: PartialMeta, alloc: std.mem.Allocator meta.description orelse null, meta.content_type orelse null, meta.sensitive orelse null, + DateTime.now(), }, alloc); } @@ -134,9 +135,9 @@ pub fn create(db: anytype, owner_id: Uuid, meta: FileMeta, data: []const u8, all try db.exec( \\UPDATE file_upload - \\SET status = 'uploaded' + \\SET status = 'uploaded', updated_at = $2 \\WHERE id = $1 - , .{id}, alloc); + , .{ id, DateTime.now() }, alloc); return id; }