Created
July 9, 2018 15:39
-
-
Save olegchir/6cc174e14bb6a58cff713021d044ce06 to your computer and use it in GitHub Desktop.
This file contains 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
SQLClientHelper.inTransactionSingle(client, sqlConnection -> { | |
return sqlConnection.rxExecute("INSERT INTO albums (name) VALUES ('The Israelites')") | |
.andThen(sqlConnection.rxExecute("INSERT INTO tracks (album, name) VALUES ('The Israelites', 'Israelites')")) | |
.andThen(sqlConnection.rxExecute("INSERT INTO tracks (album, name) VALUES ('The Israelites', 'Too Much Too Soon')")) | |
.andThen(sqlConnection.rxQuery("SELECT name FROM tracks WHERE album = 'The Israelites'").map(ResultSet::getResults)) | |
}).map(rows -> { | |
// Transform DB rows into a client-friendly JSON object | |
}).subscribe(json -> { | |
// Send JSON to the client | |
}, t -> { | |
// Send error to the client | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment