neumino / thinky

JavaScript ORM for RethinkDB
http://justonepixel.com/thinky/
Other
1.12k stars 128 forks source link

Allow formatting response #240

Closed vjpr closed 9 years ago

vjpr commented 9 years ago

I want to return Points to my client in the format of [lat, lng]. At the moment they are:

"$reql_type$": "GEOMETRY",
"coordinates": [
  49.4186,
  8.67689
],
  "type": "Point"

Is there any way to specify this for a nested join? Or do I just use something like jsonpath to format my responses to my liking. Bookshelf has format/parse commands for this purpose.

neumino commented 9 years ago

You can add a hook after retrieving and before saving to format a ReQL point to any format you want (including [lat, lng] - note that in RethinkDB it's [lng, lat]). See http://thinky.io/documentation/api/model/#pre and http://thinky.io/documentation/api/model/#post