Reputation: 109
I want to write this query in MongoDB select * from raw
, which has "1st connector" as 1
of the column.
I have written:
db.raw.find({},{"1st Connector":1})
I am getting the following results:
> db.raw.find({},{"1st Connector":1})
{ "_id" : ObjectId("548b4e270f02f305e8220370") }
{ "_id" : ObjectId("548b4e270f02f305e8220371") }
When I write "1st connector" without quotes, I get an error:
> db.raw.find({},{1st Connector:1})
2015-02-27T09:50:20.956-0800 SyntaxError: Unexpected token ILLEGAL
I want to see the actual data, i.e. contents of all these objects. How can I see that?
When I do db.raw.find()
, I get all the data.
I wrote a similar query and I got the following result:
> db.raw.find({},{entityType:1})
{ "_id" : ObjectId("548b4e270f02f305e8220370"), "entityType" : "parishes" }
{ "_id" : ObjectId("548b4e270f02f305e8220371"), "entityType" : "parishes" }
{ "_id" : ObjectId("548b4e270f02f305e8220372"), "entityType" : "parishes" }
Also, I don't know why am I getting entityType
in result here.
Upvotes: 1
Views: 46
Reputation: 61253
I have written :
db.raw.find({},{"1st Connector":1})
Because your probably don't have field named "1st Connector"
in your document.
I write 1st connector, I get error
2015-02-27T09:50:20.956-0800 SyntaxError: Unexpected token ILLEGAL
Because 1st Connector
should be quoted
wrote a similar query and I got the following result:
db.raw.find({},{entityType:1})
{ "_id" : ObjectId("548b4e270f02f305e8220370"), "entityType" : "parishes" }
{ "_id" : ObjectId("548b4e270f02f305e8220371"), "entityType" : "parishes" }
{ "_id" : ObjectId("548b4e270f02f305e8220372"), "entityType" : "parishes" }
Because your have entityType
field in your document and the second argument in find
is the projection
argument this is pretty clear in the documentation
Upvotes: 1