It actually says “objects other than ObjectIds”. Meteor does support ObjectIds as ids. Maybe you have defined your own object type to use as an _id?
EDIT: Actually, that’s spectacularly easy to do in the aggregation pipeline. If you use $group, for example, then you frequently define a non-ObjectId object for the grouping _id. If that’s where you believe you’re seeing this, you will need to make those _ids strings (or ObjectIds).
indeed the Error message is confusing because my _id is generated like this : const id = new Meteor.Collection.ObjectID();
but the problem seems in the plug-in as it was stated in this issue
I tried to empty my DB and use String IDs, it did work but I want to keep my _id field as ObjectID.
I’m not using $group, actually I’m using aggregation because I want to match my ISODate field to a regex , so I’m using it in this way:
pipe= [
{$project:{ -somefields- ,date : { $dateToString: { format: “%Y-%m-%d”, date: “$lastUpdate” } } }},
{$match:{ date: /searchinput.*/i }},
]
I couldn’t find another way to search through ISODate field (I’m open to a better solution if there is one)
EDIT: I was hoping this works but it doesn’t : $project:{ _id : “$_id._str”,…}.
Is there a way to extract the String from the ObjectID in the $project stage ?
You’re correct when you say that you can’t match a regex in a standard query. However, I’d first ask if a regex is strictly necessary? There can be massive performance hits using regex. Are you able to use ranged date queries instead?
As for _ids in the aggregation pipeline, the $project operator passes the _id through unchanged (unless you’ve specifically excluded it), so I’m still unclear what’s happening in your use case. Perhaps, some more code may help?
I ended up splitting the date on the insert and keep something like this { day , month , year } as strings . This way I can stick with only find() without the need of aggregation.
Thank you very much for your help, much appreciated