On Wednesday, June 13, 2012 6:09:07 PM UTC+2, Jason Liszka wrote:
> Hm, not sure without looking at how your models are declared, in
> particular the types of all the fields involved. Could you send that over?
> On Tue, Jun 12, 2012 at 9:50 AM, stephanos wrote:
>> Hm, when I use
>> AppCol
>> .where(_._id eqs sourceId)
>> .scan(_.team.subfield(_.members.subfield(_.user.subfield(_.id))) in
>> List(userId))
>> .select(_.team.subfield(_.members))
>> .get().headOption.getOrElse(Empty).getOrElse(List()).headOption
>> it says
>> java.lang.ClassCastException: com.mongodb.BasicDBList cannot be cast to
>> scala.collection.TraversableLike
>> On Tuesday, June 12, 2012 1:19:56 PM UTC+2, stephanos wrote:
>>> I'm having a little trouble with subselects and can't figure out why. I
>>> have a collection of apps, each document has a field 'team' where 'team
>>> members' are listed.
>>> To find a team member via his user id I wrote this:
>>> def findTeamMember(appId: Int, userId: ObjectId): Option[TM] =
>>> for {
>>> result <- AppCol.where(_._id eqs appId)
>>> .scan(_.team.subfield(_.**members.subfield(_.user.**subfield(_.id)))
>>> in List(userId))
>>> .select(_.team.subselect(_.**members)).get()
>>> members <- result.headOption
>>> member <- members.headOption
>>> } yield member
>>> But I keep getting this error:
>>> Caused by: java.lang.ClassCastException: com.mongodb.BasicDBList cannot
>>> be cast to scala.collection.immutable.**List
>>> at com.mycompany.TeamReader$$**anonfun$findTeamMember$9$$**
>>> anonfun$apply$14.apply(**TeamReaderComp.scala:62)
>>> at scala.Option.flatMap(Option.**scala:146)
>>> at com.mycompany.TeamReader$$**anonfun$findTeamMember$9.**
>>> apply(TeamReaderComp.scala:62)
>>> at com.mycompany.TeamReader$$**anonfun$findTeamMember$9.**
>>> apply(TeamReaderComp.scala:58)**
>>> at scala.Option.flatMap(Option.**scala:146)
>>> at com.mycompany.TeamReader.**findTeamMember(TeamReaderComp.**
>>> scala:58)
>>> *What could I do about it?*