jherran
jherran

Reputation: 3367

Extract String value from Node

I'm trying to query a database using something like this:

let db = drop.database?.driver as? MySQLDriver
let query = "select \(fields) from \(table) where \(condition)"
let result = try db.raw(query)

I get the following Node object as result:

array([Node.Node.object(["field_name": Node.Node.string("value_info")])])

How can I get the value_info into a String variable?

Upvotes: 1

Views: 135

Answers (1)

tanner0101
tanner0101

Reputation: 4065

You can use PathIndexable to step into the result object, then Polymorphic to cast it as a string.

Should look something like this:

let valueInfo = result[0, "field_name"]?.string

Upvotes: 1

Related Questions