When I first started experimenting with Mongo, I didn’t set up any formal kind of schema. I just imported data from a Google sheet. Frankly, I don’t remember if during the import it allowed for defining the schema during import.
I’ve used PHP in mysql since gasp the early 2000’s but I really wanted to modernize with mongo.
Well, there’s a bit of a learning curve. It’s not that difficult to understand how the database works.
That being said, I’m having a lot of issues with my queries. I think some of these issues are stemming around, not having a proper schema.
For example, I have a field I call date_added and I believe that is set as a string instead of date and I believe that’s causing a lot of issues with some of the queries I’m trying to make.
I’ve contemplated starting completely from scratch and rebuilding an entire new database exactly how it should have been created in Mongo….but I’d rather just change the database I currently have.
Could somebody please give me a step-by-step “best practice” approach on how to take a look at my current MongoDB and make the proper changes to the schema. For example, how do I change date_added from string to date?
It’s fairly simple to do for each individual document, but I’d rather make a mass change across the whole DB for the date_added field.
I have tried poking around in googling, but I can’t seem to find exactly what I’m looking for. It seems that every time I do a Google search I come up with somebody’s way to accomplish this by writing five or six lines of JavaScript and it just seems to me there’s gonna be a much easier way to accomplish such a simple thing.
Any suggestions? Thanks