ScottyBlades
ScottyBlades

Reputation: 13963

How to execute postgresql or sql directly using fluent orm

I am writing a vapor application, and I am having trouble because I need to index a geohash, but it isn't easily available, now i'd like to use SQL or postgres directly however, I'm at a loss for how for that as well.

I've Google searched for how, asked gpt, and I am not seeing a way in the framework.

Upvotes: 1

Views: 69

Answers (1)

imike
imike

Reputation: 5646

Vapor Docs gives you the answer here

import FluentPostgresDriver

if let postgres = req.db as? PostgresDatabase {
    // The underlying database driver is PostgreSQL.
    postgres.simpleQuery("SELECT * FROM planets").all()
} else {
    // The underlying database is _not_ PostgreSQL.
}

Upvotes: 2

Related Questions