The MongoDB docs state that one can use the mongo client console to initialize replica sets by running
rs.initiate([config]). However, I don't want to have to manually use the command line for this. There is a driver method called
Admin.command in the docs but I don't know how that would work here. How do I automate configuring replica sets using the MongoDB JS driver?
I have a js script that initializes my database installation by creating the data folder and automatically setting up users for access control. I want it to also configure the replica set so the database is completely ready to use after running it. I'm using MongoDB 4.2.1 and driver version 3.3.