MongoDb $merge is not adding/ updating data to collection

I tried to use $merge function in the aggregate method. I included the $merge function at last of aggregate pipeline as recommended in docs. But when I tried to execute it, getting this error in mongo shell

MongoError: Failed to retrieve database or collection name from $merge. err=Error parsing $merge value. err=not bson string Ranks
    at mongodb/mongonet@v0.0.0-20210305130450-5aed3aa353c3/bsonutil.go:137
    at fbe0a95f5df59bca2215eab28e6856ca/atlasproxy/session_proxy.go:1595
    at fbe0a95f5df59bca2215eab28e6856ca/atlasproxy/commands_security.go:1252
    at fbe0a95f5df59bca2215eab28e6856ca/atlasproxy/commands.go:1306
    at fbe0a95f5df59bca2215eab28e6856ca/atlasproxy/commands.go:1192
    at fbe0a95f5df59bca2215eab28e6856ca/atlasproxy/session_proxy.go:841
    at fbe0a95f5df59bca2215eab28e6856ca/atlasproxy/session_proxy.go:548
    at fbe0a95f5df59bca2215eab28e6856ca/atlasproxy/session_proxy.go:1426
    at fbe0a95f5df59bca2215eab28e6856ca/atlasproxy/session_proxy.go:974
    at mongodb/mongonet@v0.0.0-20210305130450-5aed3aa353c3/proxy_session.go:418
    at mongodb/mongonet@v0.0.0-20210305130450-5aed3aa353c3/proxy_session.go:122
    at mongodb/mongonet@v0.0.0-20210305130450-5aed3aa353c3/session.go:94
    at src/runtime/asm_amd64.s:1374

The aggregate function is working fine and producing result as expected. But only the $merge is not working. Please help to resolve this

I'm trying to use merge like this in aggregate:

db.collections.aggregate([


...


{ $merge: 'Ranks'}


])

Note: My Database contains the Ranks collection and I'm using cloud mongo