thinky icon indicating copy to clipboard operation
thinky copied to clipboard

Points -> Arrays in toJSON()?

Open yocontra opened this issue 8 years ago • 2 comments

Currently when calling model.toJSON() you get this:

"endLocation": {
"$reql_type$": "GEOMETRY",
"coordinates": [
40.719212,
-73.958426
],
"type": "Point"
}

It seems appropriate to instead do this:

"endLocation": [
  40.719212,
  -73.958426
  ]

Thoughts?

yocontra avatar May 30 '16 23:05 yocontra

Hum, I'm worried people will try to do stuff like filter(r.row("endLocation").nth(0) < 10) RethinkDB maps a few reql objects to native ones: groups, dates, but not location.

If we were to provide a better interface for locations, I would rather wrap things in an object created by a library that let's me do more things with locations - not just an array.

neumino avatar Jun 25 '16 16:06 neumino

@neumino Talking strictly about having an instance of a model and calling toJSON() on it, nothing to do with querying.

new Model({
  location: r.point(lon, lat)
}).toJSON()

yocontra avatar Jun 25 '16 17:06 yocontra