Upgrading to 2.2.0: setting DateTime fields

58 views
Skip to first unread message

Adam Warski

unread,
Jan 10, 2014, 9:19:19 AM1/10/14
to rogue...@googlegroups.com
Hello,

another common compilation that I have when upgrading from rogue 1.1.8 to 2.2.0 is:

    could not find implicit value for evidence parameter of type com.foursquare.rogue.BSONType[java.util.Calendar]

when trying to modify a net.liftweb.record.field.DateTimeField (or OptionalDateTimeField):

    someMeta.where(_.id eqs id).modify(_.deletedAt setTo now)

where now has type java.util.Calendar (as required by the DateTimeField).
Is it possible to set a DateTimeField using Rogue in 2.2.0?

-- 
Thanks,
Adam

Tim Nelson

unread,
Jan 10, 2014, 9:27:09 AM1/10/14
to rogue...@googlegroups.com
Rogue does not support Calendar. You need to use the DateField that's in the net.liftweb.mongodb.record.field package.

Also, note that you can use either Date or Joda's DateTime in your query.

Tim

Adam Warski

unread,
Jan 10, 2014, 10:31:09 AM1/10/14
to rogue...@googlegroups.com
I see, migrating to DateField then :) Using Joda in the queries will be great for sure :)

Thanks,
Adam

--
You received this message because you are subscribed to a topic in the Google Groups "rogue-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rogue-users/6MhUJOIjai8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rogue-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


David Boon

unread,
Feb 11, 2014, 1:49:16 PM2/11/14
to rogue...@googlegroups.com
I have this same error when trying to add orderDesc on a DateTimeField

class UserEvent extends MongoRecord[UserEvent] with ObjectIdKey[UserEvent] with IndexedRecord[UserEvent] {

  def meta: MongoMetaRecord[UserEvent] = UserEvent
  object pid extends ObjectIdField(this)
  object createdOn extends DateTimeField(this)
  object changedOn extends DateTimeField(this)



And then later when trying to sort on that field:
val userEvents = UserEvent.where(_.pid eqs new ObjectId(id)).and(_.kind eqs "users.login").orderDesc(_.createdOn).fetch(limit.getOrElse(10))

Generates: 
could not find implicit value for evidence parameter of type com.foursquare.rogue.BSONType[java.util.Calendar]

Any suggestions?

David Boon

unread,
Feb 11, 2014, 1:53:45 PM2/11/14
to rogue...@googlegroups.com
I also tried, the newer JodaTimeField

could not find implicit value for evidence parameter of type com.foursquare.rogue.BSONType[org.joda.time.DateTime]
[error]                   val userEvents = UserEvent.where(_.pid eqs new ObjectId(id)).and(_.kind eqs "users.login").orderDesc(_.createdOn).fetch(limit.getOrElse(10))

David Boon

unread,
Feb 11, 2014, 1:56:39 PM2/11/14
to rogue...@googlegroups.com
Changed to DateField, compilation errors resolved and sorting works....

class UserEvent extends MongoRecord[UserEvent] with ObjectIdKey[UserEvent] with IndexedRecord[UserEvent] {

  def meta: MongoMetaRecord[UserEvent] = UserEvent
  object pid extends ObjectIdField(this)
  object createdOn extends DateField(this)
  object changedOn extends DateField(this)
Reply all
Reply to author
Forward
0 new messages