hy guys!
im using lift-mongodb-record 2.4. All of my MongoRecord models include the following DateTimeFieldfield, eg:
object created_at extends DateTimeField(this)
when i call asJSON on this model, it'll parse the date into a string e.g.
Mon, 16 Jul 2012 21:26:58 GMT
I would prefer other formats (eg. ISO 8601, depends on the acutal use-case)
how and where would I set up a custom format?
thanks
val json:JValue = parse(request.body)
var artifact = Artifact.fromJValue(json).get
artifact.save
2.) i've to manually set artifact.deleted_at(None) otherwise I'll contain the current date (also for updates), how could i prevent this?
3.) i'm using the save method to update a model - can I whitelist certain attributes, that can be updated but some cannot after creation?
4.) to receive items, i'm using Rogue and the following snippet which is working really nice! but i'll still give back created_at: "Wed, 18 Jul 2012 11:28:08 GMT" where i would like to have something like "1997-07-16T19:20+01:00" - any suggestion?
val artifacts = Artifact where (_.deleted_at exists false)
val jval = JArray(artifacts.map(x => x.asJValue))
halt(200, pretty(render(jval)))
thank you for any support on this! so far it's been a pleasure to work with the lift project and it saved me a lot of time!
Hi Tim,thanks again for helping me out! I think i need to clarify some more broader facts to really get how to deal with mongorecord and the date stuff.Could you maybe approve the following code-snippets and check if i'm using mongorecord correctly?1.) i'm not using lift as a framework but scalatra - so i'll create an object using the following syntax, is that correct?val json:JValue = parse(request.body)
var artifact = Artifact.fromJValue(json).get
artifact.save
2.) i've to manually set artifact.deleted_at(None) otherwise I'll contain the current date (also for updates), how could i prevent this?
3.) i'm using the save method to update a model - can I whitelist certain attributes, that can be updated but some cannot after creation?
4.) to receive items, i'm using Rogue and the following snippet which is working really nice! but i'll still give back created_at: "Wed, 18 Jul 2012 11:28:08 GMT" where i would like to have something like "1997-07-16T19:20+01:00" - any suggestion?
val artifacts = Artifact where (_.deleted_at exists false)
val jval = JArray(artifacts.map(x => x.asJValue))
halt(200, pretty(render(jval)))