Created
October 28, 2016 04:22
-
-
Save jwoertink/18552383780bfb2e76c39b9b3c36a1fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "kemal" | |
require "pg" | |
DB = PG.connect(ENV["DATABASE_URL"]) | |
get "/" do |env| | |
env.response.content_type = "application/json" | |
result = DB.exec("SELECT id, username FROM members LIMIT 1000") | |
result.to_hash.to_json | |
end | |
Kemal.run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error in ./api.cr:9: instantiating 'Array(Hash(String, Array(Bool | Nil) | Array(Bool) | Array(Char | Nil) | Array(Char) | Array(Float32 | Nil) | Array(Float32) | Array(Float64 | Nil) | Array(Float64) | Array(Int16 | Nil) | Array(Int16) | Array(Int32 | Nil) | Array(Int32) | Array(Int64 | Nil) | Array(Int64) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Geo::Point) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Array(String | Nil) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | Nil))#to_json()' | |
result.to_hash.to_json | |
^~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:3: instantiating 'String:Class#build()' | |
String.build do |str| | |
^~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/string.cr:234: instantiating 'String::Builder:Class#build(Int32)' | |
String::Builder.build(capacity) do |builder| | |
^~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/string.cr:234: instantiating 'String::Builder:Class#build(Int32)' | |
String::Builder.build(capacity) do |builder| | |
^~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:3: instantiating 'String:Class#build()' | |
String.build do |str| | |
^~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:4: instantiating 'to_json(String::Builder)' | |
to_json str | |
^~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:225: instantiating 'String::Builder#json_array()' | |
io.json_array do |array| | |
^~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:225: instantiating 'String::Builder#json_array()' | |
io.json_array do |array| | |
^~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:226: instantiating 'each()' | |
each do |element| | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/indexable.cr:151: instantiating 'each_index()' | |
each_index do |i| | |
^~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/indexable.cr:151: instantiating 'each_index()' | |
each_index do |i| | |
^~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:226: instantiating 'each()' | |
each do |element| | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:227: instantiating 'JSON::ArrayBuilder(String::Builder)#<<(Hash(String, Array(Bool | Nil) | Array(Bool) | Array(Char | Nil) | Array(Char) | Array(Float32 | Nil) | Array(Float32) | Array(Float64 | Nil) | Array(Float64) | Array(Int16 | Nil) | Array(Int16) | Array(Int32 | Nil) | Array(Int32) | Array(Int64 | Nil) | Array(Int64) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Geo::Point) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Array(String | Nil) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | Nil))' | |
array << element | |
^~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:54: instantiating 'push(Hash(String, Array(Bool | Nil) | Array(Bool) | Array(Char | Nil) | Array(Char) | Array(Float32 | Nil) | Array(Float32) | Array(Float64 | Nil) | Array(Float64) | Array(Int16 | Nil) | Array(Int16) | Array(Int32 | Nil) | Array(Int32) | Array(Int64 | Nil) | Array(Int64) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Geo::Point) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Array(String | Nil) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | Nil))' | |
push value | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:59: instantiating 'push()' | |
push { value.to_json(@io) } | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:59: instantiating 'push()' | |
push { value.to_json(@io) } | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:59: instantiating 'Hash(String, Array(Bool | Nil) | Array(Bool) | Array(Char | Nil) | Array(Char) | Array(Float32 | Nil) | Array(Float32) | Array(Float64 | Nil) | Array(Float64) | Array(Int16 | Nil) | Array(Int16) | Array(Int32 | Nil) | Array(Int32) | Array(Int64 | Nil) | Array(Int64) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Geo::Point) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Array(String | Nil) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | Nil)#to_json(String::Builder)' | |
push { value.to_json(@io) } | |
^~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:255: instantiating 'String::Builder#json_object()' | |
io.json_object do |object| | |
^~~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:255: instantiating 'String::Builder#json_object()' | |
io.json_object do |object| | |
^~~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:256: instantiating 'each()' | |
each do |key, value| | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:256: instantiating 'each()' | |
each do |key, value| | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:257: instantiating 'JSON::ObjectBuilder(String::Builder)#field(String, (Array(Bool | Nil) | Array(Bool) | Array(Char | Nil) | Array(Char) | Array(Float32 | Nil) | Array(Float32) | Array(Float64 | Nil) | Array(Float64) | Array(Int16 | Nil) | Array(Int16) | Array(Int32 | Nil) | Array(Int32) | Array(Int64 | Nil) | Array(Int64) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Geo::Point) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Array(String | Nil) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | Nil))' | |
object.field key, value | |
^~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:27: instantiating 'field(String)' | |
field(name) { value.to_json(@io) } | |
^~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:27: instantiating 'field(String)' | |
field(name) { value.to_json(@io) } | |
^~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:27: instantiating '(Array(Bool | Nil) | Array(Bool) | Array(Char | Nil) | Array(Char) | Array(Float32 | Nil) | Array(Float32) | Array(Float64 | Nil) | Array(Float64) | Array(Int16 | Nil) | Array(Int16) | Array(Int32 | Nil) | Array(Int32) | Array(Int64 | Nil) | Array(Int64) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Geo::Point) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Array(String | Nil) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | Nil)#to_json(String::Builder)' | |
field(name) { value.to_json(@io) } | |
^~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:225: instantiating 'String::Builder#json_array()' | |
io.json_array do |array| | |
^~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:225: instantiating 'String::Builder#json_array()' | |
io.json_array do |array| | |
^~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:226: instantiating 'each()' | |
each do |element| | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/indexable.cr:151: instantiating 'each_index()' | |
each_index do |i| | |
^~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/indexable.cr:151: instantiating 'each_index()' | |
each_index do |i| | |
^~~~~~~~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:226: instantiating 'each()' | |
each do |element| | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:227: instantiating 'JSON::ArrayBuilder(String::Builder)#<<((Char | Nil))' | |
array << element | |
^~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:54: instantiating 'push((Char | Nil))' | |
push value | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:59: instantiating 'push()' | |
push { value.to_json(@io) } | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:59: instantiating 'push()' | |
push { value.to_json(@io) } | |
^~~~ | |
in /usr/local/Cellar/crystal-lang/0.19.4/src/json/to_json.cr:59: wrong number of arguments for 'Char#to_json' (given 1, expected 0) | |
Overloads are: | |
- Object#to_json() | |
push { value.to_json(@io) } | |
^~~~~~~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment