0

I have a meteor server running on my localhost port 3000. I want to connect to its mongodb using an objective C app. So far I have been unable to connect, but I believe that I have installed ObjCMongodb correctly into my project following the steps listed in the README. I use the ObjCMongodb line of code to connect MongoConnection *dbConn = [MongoConnection connectionForServer:@"127.0.0.1:3000" error:&error]; where 3000 is the port where the meteor application is running. One of my mongodb collection's is called 'messages' so I use MongoDBCollection *collection = [dbConn collectionWithName:@"messages"]; I try to do various commands as stated in the README, however none of them work. I know it must be the connection to the server that is making it fail or improper installation. Thanks for the help.

Nate
  • 1,875
  • 15
  • 27
  • 1
    Mongodb runs on 2+ your meteor web port. So that would be 3002 – Tarang Dec 16 '13 at 23:52
  • awesome thanks. Now when I try to define and update a collection the collection would be @"mydb.messages"?. When I use the mongodb shell and say `show collections` messages is one of the listed collections. Thus using the `collectionWithName:@"mydb.messages"` should work, but it doesn't. – Nate Dec 17 '13 at 00:03
  • In the shell, what does `db` or `db.getName()` give you? – paulmelnikow Dec 17 '13 at 03:31
  • @nate i think it should just be 'messages' – Tarang Dec 17 '13 at 09:27
  • 1
    db or db.getName() both return meteor. So it is 'meteor.messages'? – Nate Dec 17 '13 at 15:37

1 Answers1

1

In order to access my meteor mondgodb database I used the ObjCMongodb package here. The following code was then used as stated in the ReadMe to connect to the meteor app running on the localhost.

MongoConnection *dbConn = [MongoConnection connectionForServer:@"127.0.0.1:3002" error:&error];
MongoDBCollection *collection = [dbConn collectionWithName:@"meteor.messages"];

Where the port was 3000, but the mondgodb was +2 making it port 3002. The collectionWithName was then meteor.(my collection wanting to be accessed). Special thanks to noa and Akshat.

Nate
  • 1,875
  • 15
  • 27