2016-08-03 5 views
1

mongodb 콜렉션에서 '모두 찾기'를 시도하고 있습니다.mongo find()는 출력이없는 eval을 출력합니다.

나는 카운트 확인을받을 수 있습니다

mongo ip:port/database1 -u correctusername -p correctpassword 
--authenticationDatabase admin --eval "db.getCollection('collection_123').count()" 

을하지만

mongo ip:port/database1 -u correctusername -p correctpassword 
--authenticationDatabase admin --eval "db.getCollection('collection_123').find()" 

그것은 나 또한 노력

MongoDB shell version: 2.4.0 
connecting to: ip:port/database1 
DBQuery: database1.collection_123 -> { } 

생산을 조정할 때 find({})

그만큼 인증 오류가 아닌 것 같습니다. 첫 번째 쿼리는 작동하고 카운트를 생성합니다. 또한

mongo ip:port/database1 -u correctusername -p correctpassword 
--authenticationDatabase admin 

는 몽고 쉘에 들어가서

db.getCollection('collection_123').find() 

그리고 올바른 JSON 출력을 볼 수 있습니다.

+0

케어는? 이거 진짜 table123? – Oct

+0

@Oct 컬렉션으로 업데이트했습니다. 테스트 컬렉션 일뿐입니다. – Michael

답변

1

내가 찾은 유일한 방법은

mongo ip:port/database1 -u correctusername -p correctpassword 
--authenticationDatabase admin --eval "db.collection.find().forEach(printjson)" 

에 있지만 더 명령을 정렬하거나 제한과 같은 작동하지 않습니다으로 출력은 셸에서와 동일하지 않습니다.

업데이트

더 나은 솔루션 컬렉션 이름을 지정하는

mongo ip:port/database1 -u correctusername -p correctpassword 
--authenticationDatabase admin --eval "printjson(db.collection.find().toArray())" 
관련 문제