在mongo DB中插入值,数据类型指定Robomongo UI

时间:2016-12-28 11:37:37

标签: mongodb robo3t

db.employee_details.insert(
on_boarding_id : NumberLong(1),
user_name : String('chandan kumar'),
gender : Timestamp(),
blood_group : String('o+'),
marital_status : String('single'),
pan_no : String('CDSNJHJ8789'),
emergency_contact : Number(98989898989),
mobile_number : Number(9205972503),
hdfc_salary_account_details : Boolean(true),
hdfc_account : String('HJHGHHJ3222423'),
address : [
            {
                current : [{
                    address : String('New Nagar Deepatoli'),
                    pin_code : Number(909990),
                    city : String('ranchi'),
                    state : String('jharkhand')
                }]
            },
             {
                 parament : [{
                    address : String('Gurgaon iffco chowk'),
                    pin_code : Number(894893),
                    city : String('gurgaon'),
                    state : String('haryna') 
                 }]
             }
           ],
adhaar_no : String('4567HJFGKJGH98')
)

您好我想通过robongongo UI在mongoDB中存储这些数据,但它会产生错误请帮我解决这个问题..感谢您的支持。

1 个答案:

答案 0 :(得分:1)

您忘记在插入功能中添加花括号。

db.employee_details.insert({
    on_boarding_id: NumberLong(1),
    user_name: String('chandan kumar'),
    gender: Timestamp(),
    blood_group: String('o+'),
    marital_status: String('single'),
    pan_no: String('CDSNJHJ8789'),
    emergency_contact: Number(98989898989),
    mobile_number: Number(9205972503),
    hdfc_salary_account_details: Boolean(true),
    hdfc_account: String('HJHGHHJ3222423'),
    address: [{
            current: [{
                address: String('New Nagar Deepatoli'),
                pin_code: Number(909990),
                city: String('ranchi'),
                state: String('jharkhand')
            }]
        },
        {
            parament: [{
                address: String('Gurgaon iffco chowk'),
                pin_code: Number(894893),
                city: String('gurgaon'),
                state: String('haryna')
            }]
        }
    ],
    adhaar_no: String('4567HJFGKJGH98') 
})