The problem
I have successfully launched the mongo
shell on my MAC OSX environment. I am resourcing the following links and documentation to figure out the simple task of getting into a database, then a collection, then querying documents within the collection:
Accessing a database from MongoDB documentation,
Accessing a collection and documents, here on Stackoverflow, and Accessing a collection from Tutorials Point.
I created and loaded the database through the PyMongo
API. This successfully created a database named UCI-Database
, a collection named income
, and filled it with a bunch of documents (rows) from .csv
document.
So far ..
These are my results...
Blakes-MacBook-Pro:nosql bmc$ mongo 127.0.0.1:27017
MongoDB shell version v3.4.4
connecting to: 127.0.0.1:27017
MongoDB server version: 3.4.4
Server has startup warnings:
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten]
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten]
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten]
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> show dbs
UCI-Database 0.006GB
admin 0.000GB
local 0.000GB
test-database 0.000GB
> use UCI-Database
switched to db UCI-Database
> show collections
income
profiles
>
And income
is for sure the collection I created to store my rows from UCI's Adult income repository. As stated in the mongo db documentation:
db.collection.find(query, projection)
Is the syntax to query a collection.
My best attempt
> db.UCI-Database.income.find({"age":35})
2017-05-16T16:38:00.846-0400 E QUERY [thread1] ReferenceError: Database is not defined :
@(shell):1:1
>
Any feedback is helpful.