// // Copyright Amazon.com Inc. or its affiliates. // All Rights Reserved. // // SPDX-License-Identifier: Apache-2.0 // // swiftlint:disable all import Amplify import Foundation extension Post { // MARK: - CodingKeys public enum CodingKeys: String, ModelKey { case id case title case status case content case createdAt case updatedAt } public static let keys = CodingKeys.self // MARK: - ModelSchema public static let schema = defineSchema { model in let post = Post.keys model.authRules = [ rule(allow: .public, operations: [.create, .update, .delete, .read]) ] model.pluralName = "Posts" model.attributes( .primaryKey(fields: [post.id]) ) model.fields( .field(post.id, is: .required, ofType: .string), .field(post.title, is: .required, ofType: .string), .field(post.status, is: .required, ofType: .enum(type: PostStatus.self)), .field(post.content, is: .required, ofType: .string), .field(post.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), .field(post.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) ) } } extension Post: ModelIdentifiable { public typealias IdentifierFormat = ModelIdentifierFormat.Default public typealias IdentifierProtocol = DefaultModelIdentifier }