to connect and query the mongodb