Hello all,
I would first like to admit that I am still fairly new to clojure, mongodb, and monger. I've tried too search around for the answer to my question and have had no luck.
I am creating a web application that is AngularJS/Luminus/Monger/MongoDB. I understand that MongoDB uses ObjectIds for _ids which I don't completely understand the reasoning for, but am willing to accept it. (Note: I know they can be used for timestamps and are good at being unique and ordering results) They seem to be difficult to work with for REST/JSON web applications, at least to me. I've honestly not heard others complaining about this problem, so I may just be thinking about it all wrong.
The current issue I'm trying to work with is how to deserialize my JSON object that is being POSTed back from my front end into the correct format for storing in the database. I'm manually having to check for the _id field and running monger.conversion/to-object-id, which I feel is a headache, but the bigger issue is if one document has an array of references to other documents (many-to-many). I am able to retrieve it from the database, serialize it such that JSON can handle passing it to my front end, however, when I retrieve a modified version back, I don't have an easy way to know what should be converted back to ObjectIds. I could hardcode looking for the field that stores this array and run through and convert it, but that just doesn't seem like the ideal way to do it.
I've tried searching for information about strict mode, as I found that it handles JSONifying data by using $oid fields to reference, but from what I can tell, that is through MongoDBs REST API and only works for retrieval, not for inserting.
I also see some people going the route of not using ObjectIds as their _ids and opting for strings or numbers. It seems like an acceptable approach according to Mongo, but just not their preferred way. And if you forget to add an _id they will create one for you using ObjectIds which could just throw the whole thing off.
TL;DR
My question is this: How do you all handle working with deserializing JSON data correctly for a document that has an array of referencing document ObjectIds?
Thanks!