Today was mostly a research-oriented day for me. I need to look into creating a front end API with a nice user interface for Engineering.com to use to query our back end API. I have two main ideas right now:
A) A very powerful UI that would learn about the schema as the user clicks on things to give them buttons etc for every possible Mongo query they could do. For example, if they clicked "Hit", they'd get a few buttons popping up below listing the attributes or "Session" because there's a many-to-one relationship between Hit and Session. This thing would learn forever, and always work for them, even as they add more data to the schema.
B) A simple UI with as many queries that we can come up with as possible based on our current schema. They would be sorted into categories so it would make sense, but because it's just a set of queries we've prepared, it wouldn't grow in the future.
A is extremely hard. I practiced making a mock up in HTML (no functionality) and I still couldn't even wrap my mind around how it would all connect together. I looked online for some open source libraries in case anybody had already created this "visual query" tool, and I couldn't find any.
B is more feasible. My team mate agrees with me so far with this.
I began looking into an ODM (object document mapper) called Mongoose to make our lives easier as we make this. They let you use programming-like code to traverse the cardinal relationships among your models. Instead of making a query to get the id of a certain session, and then finding all hits based on that id (two separate queries, lots of code), we can do something "findTheSession().hits". Done. Boom.
I love these mappers. I've used ActiveRecord with Rails and Entity Framework with .NET, so this feels familiar. Once I get passed the growing pains of learning how to set it up, I think it will speed us up a lot. We didn't need to use an ODM for the back end API because it wasn't doing any reading of our database, just taking in simple objects and inserting them into the database.
Over the next few days I'm going to continue playing with Mongoose, but also brainstorm types of queries to help Engineering.com analyze their data, and think about the UI we'll create.
Note: This was originally posted on the blog I used for my co-op term while at Seneca College (mswelke.wordpress.com) before being imported here.