fehmicansaglam / reactivemongo-extensions

ReactiveMongo Extensions
Apache License 2.0
14 stars 4 forks source link

Dynamic collection name #8

Closed ChristoRibeiro closed 10 years ago

ChristoRibeiro commented 10 years ago

Hi Fehmi,

There is a way to change the collection name dynamically with the JsonDao and work with JsObject (without case class)? I'm working with several collection dynamically, each one can be created or removed on the fly.

For example:

object DataStore extends JsonDao[JsObject, BSONObjectID](Mongo.db)

DataStore.collection("myCollection1").find()
DataStore.collection("myCollection2").find()

// or more easy

DataStore("myColleciton1").find()
DataStore("myColleciton2").find()

No case class, just an easy way to access on different collection with the magic power of reactivemongo extensions :)

fehmicansaglam commented 10 years ago

I haven't tried but JsObject should work as is.

Currently there is no way of specifying the collection name dynamically. I have also been thinking of it. Give me 2 or 3 days time or submit a PR :)

ChristoRibeiro commented 10 years ago

I can look for a PR, but maybe you'll be more faster than me.

Anyway, I think the above way could be very interesting for many people.

fehmicansaglam commented 10 years ago

Agreed. Expect a snapshot release soon.

fehmicansaglam commented 10 years ago

I have released a new snapshot: 0.10.0.5-SNAPSHOT. There is no documentation yet. Can you review the test code and comment on usability? https://github.com/fehmicansaglam/reactivemongo-extensions/blob/0.10.x/json/src/test/scala/dao/DynamicJsonDaoSpec.scala

ChristoRibeiro commented 10 years ago

Looks like a natural extension of existing features :+1:

I did some tests and everything seems to work

fehmicansaglam commented 10 years ago

Cool! We are also releasing a snapshot from ReactiveMongo organization today.