Reputation: 314
So basically I have this collection where objects are stored with a string parameter. example:
{"string_": "MSWCHI20160501"}
The last part of that string is a date, so my question is this: Is there a way of writing a mongo query which will take that string, convert part of it into an IsoDate object and then filter objects by that IsoDate.
p.s I know I can do a migration but I wonder if I can achieve that without one.
Upvotes: 2
Views: 78
Reputation: 1168
Depending on the schema of your objects, you could hypothetically write an aggregation pipeline that would first transform the objects, then filter the results based on the results and then return those filtered results.
The main reason I would not recommend this way though is that, given a fairly large size for your dataset, the aggregation is going to fail because of memory problems.
And that is without mentioning the long execution time for this command.
Upvotes: 1