drift-org / backend

2 stars 0 forks source link

Fix Challenge Model #51

Open anjanbharadwaj opened 3 years ago

anjanbharadwaj commented 3 years ago

In the challenge model, address/location are left as non-required fields. When creating a Challenge via Mongo Compass (inserting a document with something like {"_id":{"$oid":"60caaa7cff0df79a62f2cadb"},"location":{"type":"Point","coordinates":[{"$numberDouble":"1.234"},{"$numberDouble":"1.234"}]},"taskName":"find a bench","description":"Try looking for a bench in a park","points":{"$numberInt":"3"}}) the document seems to create fine. However, when I try creating the document via a Gin route (#26), I get this error in Postman: unknown GeoJSON type: { type: \"\", coordinates: null }}]}, {<nil>}]

If I follow the instructions from here and set Location type to "Point" but leave coordinates empty, I get: Point must be an array or object}]}, {<nil>}]

Seems like we might have an issue in keeping these fields optional because of the geolocation indexes we have setup for the challengeCollection -- may need to find a workaround?

anjanbharadwaj commented 3 years ago

@teekenzie thoughts?

teekenzie commented 3 years ago

@anjanbharadwaj I fixed the issue, check out the latest commit on the branch feat/#26