Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
How to use a string PostgreSQL query in Vapor using Fluent?

I'm using Vapor 4 beta to write some APIs. I have a PostgreSQL database running in the background and I want to filter a table, and check if a particular row was created in a certain interval of dates.

My query should be like:

SELECT *
FROM notes
WHERE date BETWEEN '2020-07-03' AND '2020-07-04'

The query works great with the database (I tried it with Postico client), however I want to use it with Fluent in Xcode.

I tried something like this:

func retrieveNotes(req : Request) throws -> EventLoopFuture<[Note]> {
    guard let userID = req.parameters.get("userID", as: UUID.self) else {throw Abort(.notFound)}
    if let postgres = req.db as? PostgresDatabase {
        return postgres.query("SELECT * FROM notes WHERE date BETWEEN '2020-07-03' AND '2020-07-04")
    } else {
        //throw some errors
    }
}

It doesn't work, and it says: "Cannot convert return expression of type 'EventLoopFuture' to return type 'EventLoopFuture<[Note]>'"

How can I cast my result, or resolve this problem in some way?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda