2013-04-19 4 views
0

MongoDB에서 아래의 형식으로 새 콜렉션을 작성하려고했습니다. 그러나 나는 그렇게 할 수 없다.MongoDB에서 콜렉션을 생성 할 수 없습니다.

다음은 내 컬렉션 생성 코드입니다. 누구든지 동일한 코드 묶음을 시도하십시오. & 컬렉션 생성을 시도하십시오. 같은 것을 도와주세요. 미리 감사드립니다.

db.MasterAccount_AccountUser.insert 
(
{ 
MasterAccountID: 100, 
MasterAccountName: 'LMS Plumber Inc', 
AccountOwner: 'John', 
AccountUser:[ 
     { 
     AccountUserID: 1001, 
     AccountUserName: 'John', 
     AccountUserRole: 'Admin', 
     AccountUserEmailID: '[email protected]', 
     AccountUserPhoneNumber: '8132546363' 
      }, 
     { 
     AccountUserID: 1002, 
     AccountUserName: 'Matt', 
     AccountUserRole: 'User', 
     AccountUserEmailID: '[email protected]', 
     AccountUserPhoneNumber: '8132546362' 
     }, 
     { 
     AccountUserID: 1003, 
     AccountUserName: 'Dan', 
     AccountUserRole: 'User', 
     AccountUserEmailID: '[email protected]', 
     AccountUserPhoneNumber: '8132568945' 
     } 
     ]  
    } 
) 

감사합니다.

+0

감사합니다. 수정 된 코드 블록과 함께 이번에는 오류없이 코드가 잘 실행됩니다. 그러나 "show.collections"를 요청하면 새로운 컬렉션 이름이 표시되지 않습니다. MasterAccount_AccountUser. – 0nir

답변

2

이것은 쉘에 의해 두 개의 별도 명령문으로 취급됩니다.

첫 번째는 db.MasterAccount_AccountUser.insert이고 두 번째 문은 코드의 나머지 부분입니다. (을 첫 번째 행으로 이동하면 전체를 하나의 문장으로 취급하게됩니다. 좋아요 :

db.MasterAccount_AccountUser.insert(
{ 
MasterAccountID: 100, 
MasterAccountName: 'LMS Plumber Inc', 
AccountOwner: 'John', 
AccountUser:[ 
     { 
     AccountUserID: 1001, 
     AccountUserName: 'John', 
     AccountUserRole: 'Admin', 
     AccountUserEmailID: '[email protected]', 
     AccountUserPhoneNumber: '8132546363' 
      }, 
     { 
     AccountUserID: 1002, 
     AccountUserName: 'Matt', 
     AccountUserRole: 'User', 
     AccountUserEmailID: '[email protected]', 
     AccountUserPhoneNumber: '8132546362' 
     }, 
     { 
     AccountUserID: 1003, 
     AccountUserName: 'Dan', 
     AccountUserRole: 'User', 
     AccountUserEmailID: '[email protected]', 
     AccountUserPhoneNumber: '8132568945' 
     } 
     ]  
    } 
) 
+1

이것은 JavaScript 구문 때문입니다. JsLint (http://www.jslint.com/)에서이를 확인할 수 있습니다. 누락 된 것이 (메서드 이름 바로 다음에) 표시됩니다. – philnate

+0

감사합니다. 정말 도움이되었습니다. – 0nir

관련 문제