Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete all query hanging #426

Closed
tanner0101 opened this issue Mar 27, 2018 · 0 comments
Closed

delete all query hanging #426

tanner0101 opened this issue Mar 27, 2018 · 0 comments
Assignees
Labels
bug Something isn't working
Projects

Comments

@tanner0101
Copy link
Member

   func resetData(req: Request) throws -> Future<Response> {
       return Post.query(on: req).delete().map(to: Response.self) {
           return Response(http: HTTPResponse(status: .ok), using: req)
       }
   }
import Foundation
import FluentMySQL
import Vapor

struct Post: Content, MySQLModel, Migration {
    var id: Int?
    var title: String
    var strap: String
    var content: String
    var category: Int
    var slug: String
    var date: Date
    
    static func prepare(on connection: MySQLConnection) -> Future<Void> {
        return MySQLDatabase.create(self, on: connection) { builder in
            try builder.field(type: .int64(), for: \.id, isOptional: false, isIdentifier: true)
            try builder.field(for: \.title)
            try builder.field(for: \.strap)
            try builder.field(type: .text(), for: \.content)
            try builder.field(for: \.category)
            try builder.field(for: \.slug)
            try builder.field(for: \.date)
        }
    }
}
@tanner0101 tanner0101 added the bug Something isn't working label Mar 27, 2018
@tanner0101 tanner0101 self-assigned this Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Vapor 3
  
Awaiting triage
Development

No branches or pull requests

1 participant