Converting collection to array of results

77 views
Skip to first unread message

dfr

unread,
Jan 9, 2011, 11:55:38 AM1/9/11
to mongo-scala-driver
Good day, currently to feed result of database query to velocity
template i need it converted to Array.
I have something like this:
val col = DB.realty.getCollection(table) of BoardEntry
Is it posssible to convert col to array of BoardEntry ?

I tried also to reach underlying java library which has desired method
by using col.find, but getting error:
ambiguous reference to overloaded definition,
[error] both method find in class ShapedCollection of type (q:
com.mongodb.DBObject)com.mongodb.DBCursor
[error] and method find in trait QueriedCollection of type =>
Iterator[Iterator[ru.realty.board.BoardEntry]]

Alexander Azarov

unread,
Jan 10, 2011, 2:55:41 AM1/10/11
to mongod...@googlegroups.com

09.01.2011, в 19:55, dfr wrote:

> Good day, currently to feed result of database query to velocity
> template i need it converted to Array.
> I have something like this:
> val col = DB.realty.getCollection(table) of BoardEntry
> Is it posssible to convert col to array of BoardEntry ?

MongoCollection[T] inherits Iterable[T] with all its methods, so you can call:

col.toArray

Reply all
Reply to author
Forward
0 new messages