diff --git a/Sources/QueuesFluentDriver/FluentQueue.swift b/Sources/QueuesFluentDriver/FluentQueue.swift index 0191921..94fd4cc 100644 --- a/Sources/QueuesFluentDriver/FluentQueue.swift +++ b/Sources/QueuesFluentDriver/FluentQueue.swift @@ -25,8 +25,8 @@ extension FluentQueue: Queue { .first() .unwrap(or: QueuesFluentError.missingJob(id)) .flatMapThrowing { job in - let jobData = job.data//try JSONDecoder().decode(JobData.self, from: job.data) - return jobData! + let jobData = try! JSONDecoder().decode(JobData.self, from: job.data) + return jobData } } diff --git a/Sources/QueuesFluentDriver/JobModel.swift b/Sources/QueuesFluentDriver/JobModel.swift index 7660514..4a59131 100644 --- a/Sources/QueuesFluentDriver/JobModel.swift +++ b/Sources/QueuesFluentDriver/JobModel.swift @@ -28,8 +28,8 @@ class JobModel: Model { /// The Job data @Field(key: "data") - var data: JobData? - //var data: Data + //var data: JobData? + var data: Data /// The current state of the Job @Field(key: "state") @@ -50,7 +50,7 @@ class JobModel: Model { init(id: UUID, key: String, data: JobData? = nil) { self.id = id self.key = key - //self.data = data + self.data = try! JSONEncoder().encode(data) self.state = .initial } } diff --git a/Sources/QueuesFluentDriver/JobModelMigrate.swift b/Sources/QueuesFluentDriver/JobModelMigrate.swift index cfc4792..391dcb2 100644 --- a/Sources/QueuesFluentDriver/JobModelMigrate.swift +++ b/Sources/QueuesFluentDriver/JobModelMigrate.swift @@ -13,7 +13,7 @@ public struct JobModelMigrate: Migration { return database.schema(JobModel.schema) .id() .field(model.$key.key, .string, .required) - .field(model.$data.key, .json) //, .required) + .field(model.$data.key, .data, .required) .field(model.$state.key, .string, .required) .field(model.$createdAt.path.first!, .datetime) .field(model.$updatedAt.path.first!, .datetime)