I am a little bit confused as to why sometimes aggregations using Moralis have to use the $ prefix before operators and sometimes not. I watched all the playlists on youtube but there is no mention regarding this in any of these videos nor the documentation.
When using MongoDB , operators need the $ like in $group, $or to generate aggregations. When using Moralis tho and according to the examples they dont use $ operator prefixes. Now I just found out, that on the nested operators, it wont work WITHOUT $. So sometimes with and sometimes without. Whats the general guideline / rule to this?
const pipeline = [
{ match: { $or: [{ address: '0x6262998ced04146fa42253a5c0af90ca02dfd2a3' }, { address: '0x7eb2df1cc0e8529e69988e914e6120f1400ff3e7' }] } } //this works
{ $match: { $or: [{ address: '0x6262998ced04146fa42253a5c0af90ca02dfd2a3' }, { address: '0x7eb2df1cc0e8529e69988e914e6120f1400ff3e7' }] } } //this throws error
{ match: { or: [{ address: '0x6262998ced04146fa42253a5c0af90ca02dfd2a3' }, { address: '0x7eb2df1cc0e8529e69988e914e6120f1400ff3e7' }] } } //no error no result
];
//In MongoDB Compass you have to use (both $ prefixes)
{ $match: { $or: [{ address: '0x6262998ced04146fa42253a5c0af90ca02dfd2a3' }, { address: '0x7eb2df1cc0e8529e69988e914e6120f1400ff3e7' }] } } //this works
const result = await query.aggregate(pipeline);