Closed saurabhnanda closed 8 years ago
I don't know what it's supposed to return, but it returns the number of rows inserted, presumably 1. If you want to return the ID of the newly created post you need to use runInsertManyReturning
.
Right, it returns the number of rows inserted. I'll probably shovel in a new Lesson 2b in between the current Lessons 2 & 3 - I wanted Lesson 2 to just be about how to set up Opaleye, in the simplest way I could find, but there are a lot of features which a real system would want which aren't included.
I lied; it's implemented in Lesson 2 now. I had to update runInsert
to runInsertMany
anyhow, since runInsert
is deprecated, so I just switched to returning keys.
What does this piece of code really return? Isn't it supposed to return the ID of the newly created blog post?
https://github.com/nomicflux/servant-opaleye-blog/blob/e4c1c6952cb3def9c5f573ad3321e4cce45148e8/src/Api/BlogPost.hs#L40-L41