search

Home  >  Q&A  >  body text

mongodb - mongo中内嵌列表的插入

{"name":"test","tag":[{"tname":"a","ttype":"atype"},{"tname":"b","ttype":"btype"}]}

想往mongod里插入类似于上面的数据(数据中有一个内嵌的列表),直接在mongo的shell里进行操作,应该怎么写呢?

仅有的幸福仅有的幸福2798 days ago585

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-26 09:03:27

    Okay, just ask and answer your own questions

    db.test.insert({
        "name":"test",
        "tag":[
        {"tname":"a","ttype":"atype"},{"tname":"b","ttype":"btype"}
        ]
    });
    

    reply
    0
  • Cancelreply