Fix updated_at field in api

This commit is contained in:
jaina heartles 2022-12-06 21:44:53 -08:00
parent 22f2a03308
commit 03a5112036

View file

@ -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;
}