scala-news-reader
rss/atom news reader in scala
git clone https://9o.is/git/scala-news-reader.git
ObjectIdRefListFieldExtra.scala
(505B)
1 package com.joereader.model.field
2
3 import com.mongodb._
4 import net.liftweb._
5 import common._
6 import mongodb.record._
7 import field._
8
9
10 trait ObjectIdRefListFieldExtra[
11 OwnerType <: BsonRecord[OwnerType],
12 RefType <: MongoRecord[RefType] with ObjectIdPk[RefType]]
13 extends ObjectIdRefListField[OwnerType, RefType] {
14
15 def add(a: RefType): OwnerType =
16 if (get.exists(_ == a.id.get)) owner
17 else this(a.id.get :: get)
18
19 def remove(blog: RefType) =
20 this(get.filterNot(_ == blog.id.get))
21 }