Questions tagged [vapor-fluent]

Swift ORM framework (queries, models, and relations) for building NoSQL and SQL database integrations.

Fluent (vapor/fluent) is a type-safe, fast, and easy-to-use ORM framework built for Swift. It takes advantage of Swift's strong type system to provide an elegant foundation for building database integrations.

Docs · Github

112 questions
9
votes
2 answers

Add a default value in migration in Vapor

How do I add a default value for a non-optional field in a fluent migration? I currently have this error: ⚠️ PostgreSQL Error: column "firstName" contains null values my only options are public func field(for key: KeyPath,…
Dani Pralea
  • 4,545
  • 2
  • 31
  • 49
6
votes
2 answers

In Fluent / Vapor 4, how do I filter a list based on a foreign key?

so I have models names Organization, User, and App. Apps and Users both belong to organizations. final class Organization: Model, Content { static let schema = "organizations" @ID(key: .id) var id: UUID? @Field(key: "name") var…
winsmith
  • 20,791
  • 9
  • 39
  • 49
6
votes
1 answer

Create Fluent Model with String Enum

Here is my Fluent Model struct Ailment: PostgreSQLModel { enum Frequency: String , Content { case regular = "Regular" case occasional = "Occasional" case incidentFound = "Incident Found" } var id: Int? var ailment: String var…
Vigneshkumar G
  • 328
  • 1
  • 2
  • 9
5
votes
1 answer

enum giving error with vapor 4 and fluent

This puzzles me: I have a model in which I want to use an enum. I first declare the enum: enum MenuChoices: String, Codable { case reachableAt case attentionTo case reasonVisit case reasonProblem } Then it is in my fields of the…
Glenn
  • 2,808
  • 2
  • 24
  • 30
5
votes
4 answers

Vapor 4 case insensitive query

In Vapor 3 you could use filter method with a SQLiteBinaryOperator, so you could create a query with a like operator. I'm trying to do the exact same thing in Vapor 4 but couldn't find anything for that. Here's my code Vapor 4 func queryUserMovies(_…
Rodrigo
  • 733
  • 1
  • 10
  • 26
5
votes
2 answers

Understanding how to initialize a Vapor 4 repository

I am trying to migrate some code using a Repository pattern from Vapor 3 to Vapor 4. I have gone through the documentation of this specific pattern from the Vapor 4 documentation, and I think I understand it for the most part. The one thing I am not…
Tim Dean
  • 8,253
  • 2
  • 32
  • 59
5
votes
1 answer

How can I help Vapor successfully SSL-handshake my PostgreSQL server?

I'm using Vapor on a Ubuntu server to connect to my DigitalOcean-managed PostgreSQL database. From the command-line, running the following works fine: psql postgresql://user:password@host:port/dbname?sslmode=require But running the equivalent with…
Mick F
  • 7,312
  • 6
  • 51
  • 98
4
votes
1 answer

Where do I get the database object using Vapor?

I feel like this should be straight forward, however I'm not able to find a solution. I'm creating a server using Vapor with a postgres database. I'm trying to write the class to query and store data in the database However when looking at the…
GP89
  • 6,600
  • 4
  • 36
  • 64
4
votes
1 answer

Parent Child Relation with Vapor 4

I want to set up a parent child relationship between a League and a Team in Vapor 4. I can create a League just fine, but when I try to create a new team like this: { "name": "Chicago Bulls", "league_id":…
Adam Zarn
  • 1,868
  • 1
  • 16
  • 42
4
votes
1 answer

Vapor 4/Swift: Middleware development

I'm completely new to Swift and Vapor; I'm trying to develop an Authorization Middleware that is called from my UserModel (Fluent Model object) and is past in a Required Access Level (int) and Path (string) and Ensures the user is…
4
votes
1 answer

Vapor 3: Eventloop bug detected when using wait()

I'm struggling with understanding how to perform a batch save of fetched objects and store them to the database. After I have stored the objects to the database I want to return the result of a query. I can't understand how to do this with…
Paul Peelen
  • 10,073
  • 15
  • 85
  • 168
4
votes
1 answer

MySQL & Vapor 3: unrecognized basic packet, full auth not supported

I want to connect a MySQL database on my machine with a Vapor 3 app. My current configure.swift file looks as follows: try services.register(FluentMySQLProvider()) ... let mysqlConfig = MySQLDatabaseConfig( username: "dev", password: "", …
LinusGeffarth
  • 27,197
  • 29
  • 120
  • 174
3
votes
1 answer

Find all items with empty many to many relationship in vapor fluent

Given the example from the vapor docs: // Example of a pivot model. final class PlanetTag: Model { static let schema = "planet+tag" @ID(key: .id) var id: UUID? @Parent(key: "planet_id") var planet: Planet @Parent(key:…
dehlen
  • 7,325
  • 4
  • 43
  • 71
3
votes
1 answer

How and where to Install SSL certificate on vapor 4 app?

I am trying to deploy postgres in Digital Ocean. After setting up the Managed databases, it provided ca-certificate.crt which needs to be installed on the backend app. Tech stack Vapor for backend dev DO for server As per DO, they said to refer…
user4150758
  • 384
  • 4
  • 17
3
votes
1 answer

Vapor how to transform EventLoopFuture to

I am implementing a delete route handler using Vapor Fluent. For this handler, I wanted to verify that the user sending the product deletion request is the owner of the product, and Abort the request otherwise. func deleteHandler(_ req: Request)…
Wendell
  • 474
  • 3
  • 12
1
2 3 4 5 6 7 8