I'm using mongodb Realm functions and want to run this query for all my collections in the database. I have to write a collection name; otherwise, I get this error:
'(AtlasError) Pipeline can only have no collection if the first stage is $changeStream', error_code: 'MongoDBError'
here is my code:
exports = function (payload) {
const movies = context.services
.get('mongodb-atlas')
.db('subsDB')
.collection('subtitles');
let arg = payload.query.arg;
let found=movies.aggregate([
{
$search: {
index: 'default',
text: {
query: arg,
path: {
wildcard: '*',
},
},
},
},
]);
How can I run this query on all collections in my database?