Posts

Showing posts from February, 2014

scala, slick and NotesService

I forgot to add a full version of the NotesService that was discussed in a previous blog. Let's revisit the NotesService interface: /** * Primarily for larger notes/docs storage. * The API allows the note content to be retrieved * separately. Sometimes, we want to separate * out the larger, less changing content from * our core database into a separate component. A note * can be a picture, a spreadsheet, HTML, XML or * even just a text document. While times, * these types of documents are just stored in a * standard RDBMS database, there are other options * such as a document management systems or * file-system. * * This trait does not prescribe how to * create {{{Note}}} objects. Also, the {{{Note}}}, * {{{NoteId}}} and other types will probably escape * whatever object instantiates this object * so the types will need to be accessible to the outer * world for working with the service. That means * we will have to watch-out for path-depe

scala slick and sub-selects for max value

I am learning slick. A bit of tough road initially. The blogs and other posts out there really help. This tutorial  was especially helpful. My domain was storing note objects in database and tracking revisions. Here's the table structure: class Notes ( tag : Tag ) extends Table [( Int , Int , java.sql.Timestamp , Boolean , Option [ String ])]( tag , "Notes" ) { // some dbs cannot return compound primary key, so use a standard int def id = column [ Int ]( "id" , O . AutoInc , O . PrimaryKey ) def docId = column [ Int ]( "docId" ) def createdOn = column [ java.sql.Timestamp ]( "createdOn" ) def content = column [ Option [ String ]]( "content" ) def latest = column [ Boolean ]( "latest" ) def * = ( id , docId , createdOn , latest , content ) def index1 = index ( "index1" , docId ) def index2 = index ( "index2" , crea