Hello. I am new with liftweb and scala. I am developing json-rest api for rss agregator and I have two problems:
package my.domain
import net.liftweb.http._
import net.liftweb.http.rest._
import net.liftweb.json.JsonAST._
import net.liftweb.common.{Box,Full,Empty,Failure,ParamFailure}
import my.domain.model.{RssItem}
object ContentRest extends RestHelper {
def getFirstRssItem = {
val item = RssItem.find(ByField(RssItem.title, "test"))
item.title
}
serve {
case "api" :: "static" :: _ XmlGet _=> <b>Static</b>
case "api" :: "static" :: _ JsonGet _ => JString("string")
}
}
I get errors on both first and second lines of getFirstRssItem method:
First is that compiler can't find ByField method - what i need to import?
Second is that compiler says it can't find method title in item
val. According to liftweb wiki I may call field's name as method but item
has the type Box[my.domain.model.RssItem]. What am I doing wrong?
RssItem model:
package my.domain.model
import net.liftweb.mapper._
class RssItem extends KeyedMapper[Long, RssItem] {
def getSingleton = RssItem
def primaryKeyField = id
object id extends MappedLongIndex(this)
object title extends MappedString(this, 255)
object description extends MappedText(this)
object pubDate extends MappedDateTime(this)
}
object RssItem extends RssItem with KeyedMetaMapper[Long, RssItem] {
def dbTable = "items"
}